Reputation: 301
I build some app from Ionic V1 and I want to make user stay logged in for 12 days. My problem is how to make logged in user will be discovered when the user opens the app after the user closes app? I'm new in Ionic and angular js, can you help me to solve my problem
thanks
Upvotes: 0
Views: 902
Reputation: 1104
you can use jwt token
storage functionality in localstorage to check.
like :
step 1 : when user login get the token and store it in local storage.
step 2 : check for this token every time when the app open
for eg :
when app open and first app controller run first, then emits the function in this controller to check if localstorage have token ?
if no, go to login page, login and save the token, then go to app functionality.
if yes, go directly to the app functionality (rather render login page )
step 3 : for every logout remove the token.
Upvotes: 2
Reputation: 472
You can use JSON Web Token for user session maintenance in which you can store user identity data and also set expiration time for the token, and user specific data can be fetched from server using this token. This token can be stored in Local Storage.
For more information, refer here JWT
Upvotes: 0