Page 1 of 1

Saving credential on mobile device

Posted: Mon Aug 25, 2014 9:31 am
by manjeetsharma

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


Saving credential on mobile device

Posted: Mon Aug 25, 2014 12:27 pm
by KorryRogers

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.


Saving credential on mobile device

Posted: Mon Aug 25, 2014 10:47 pm
by Yurii Orishchuk

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.