add token memory and auto log in function