How to use remember userID in login screen?

I have a app. i want to remember userID in login screen . How to do it in ionic?

Please Help me…


Two ways.

1 Save the userID into localStorage, so that if the user closes the app and comes back you will still have their userID.

window.localStorage.userID = userID;

2 If you only need it while the user is in the app, simply save it into a Service

SomeService.set(userID, userID);

So essentially you create a getter and a setter in a Service that will save the userID and then you can inject that Service into another controller and get the value.

1 Like