Stay logged in with data in local storage

Hello,

I’m trying to figure out how to stay logged in.

Persistent data in local storage must be useful in this case, I’m not sure if it is correct, to use import { Storage } from '@ionic/storage';

Advice would be useful

Logged in to what exactly?

Hello, Sujan12

Thanks for answer

To make user able to stay logged in his account settings data, which is stored on MySql database, but not attached to the particular user with logout from the application or after turning off phone

I’m new with Ionic2 and Type Script, maybe I’m not on the right direction, as I understand it, I have to create some key to attach particular user with his account, but if it is wrong, would be helpful, to know a proper method or more correct way of solution

This is an extremely complex problem with substantial security implications. I would strongly urge you to adopt tested technology like JSON Web Tokens here instead of trying to develop your own protocol. You can persist the JWT in Storage on the device and reload it on app launch. This should have the effect of “keeping the user logged in” for as long as the token itself is valid, which you can control depending on your needs.

2 Likes

Hello, rapropos

Thank you for your answer, very useful