manjeetsharma
Posts: 0
Joined: Mon Aug 25, 2014 9:31 am

Saving credential on mobile device

Hi,

For login we are making a CORS request to server.Based on the login API response we are logging in the user in application.
Now we want that user should remain logged in, even if user kiils or restart the application. how can we achieve this?

On device how to check whether the particular login cookie exists or not in appery?

Suggest me some solution which uses cookies for this.

Thanks,
Manjeet

KorryRogers
Posts: 0
Joined: Fri Aug 15, 2014 2:53 am

Saving credential on mobile device

I can tell you how we do that. When the user logs in, we generate an MD5 login hash and store that and their userID in a separate table in the database. We also store the hash and userid in a localStorage variable. Then when the app launches, we check the hash and ID against that table in the database, and either log them in or redirect them to the login screen.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Saving credential on mobile device

Hi manjeetsharma,

Here is what you need to do:

1 Store "sesionToken" to the LSV on login success event.

2 Store "userName" and "password" in the LSV on login success event.

Here is usecase:

1 User logins and receive "sessionToken".

2 On success event you store "sessionToken", "userName" and "password" to local storage variable(LSV).

3 Exit the app.

4 Open app again.

5 At first app tries to use current "sessionToken".

6 If it correct - continue to use it.

7 If "sessionToken" is not correct you make automatic login with saved in "userName" and "password" LSVs credentials.

That's all.

Regards.

Return to “Issues”