Best way to save auth credentials to make login status persistence


#1

I’m not sure whether this is the right place to ask, but I think this might be a common problem for any ionic based mobile app.

Suppose I have an app has a normal oauth flow: the user can login with username and password, and if the login success, the server send back a token that can be used in the $http header when sending a api request.

And there’s no difference to what we usually do in desktop browser. But we are now on a phone, the user will close the app, so I think we need a way to save those credentials so that when user reopen the app, they don’t need to input the username and password.

I’ve tried to store them in localStorage, but not sure whether this is the right way to do.

I’m happy to hear how you guys handle this.


#2

In my opinion as you pointed out, localStorage is the best option.