-
25 Mar 2012 8:06 AM #1
Stay logged in
Stay logged in
I've been thinking about the possibilities of letting a user "stay logged in" in a webbapp.
What do you think is the best practise?
Backend=PHP
Thanks / E
-
26 Mar 2012 6:56 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
Setting up a session on the backend and on the frontend have a check to see if the user is already logged in.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
26 Mar 2012 8:58 AM #3
Thanks,
I'd did a deep dive myself and came up with this:
- Store user and password in localstorage is probably bad though it's readable. ANtother problem is that Apple has moved it to the cache folder.
- Setting a sessioncookie in the backend will do as long as you don't close the browser.
- Using a cookie with a authentication ID (some hashed value based on some user info and a salt) that's stored in the local machine and in the user table is probably the best idea.
To consider:
- Beware of XSS
- Let the cookie expire
More ideas?
-
26 Mar 2012 9:11 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
iOS 5 also sets the cookie acceptance setting to disable cookies. I had to resort to sending a session ID to and from my apps to get around this.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
26 Mar 2012 12:18 PM #5
OK, but the cookie acceptance is user defined isn't it?
Regarding the your session solution. Doesn't the session stop when you shut down the browser?
-
26 Mar 2012 12:24 PM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
I didn't feel it a good experience to ask my user to change the cookie setting. If I were to be asked that I wouldn't use the app.
I save the session id in localstorage and store the session in a database on the backend. If the session id doesn't exist in the database then I return a new one and handle that on the front end.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
26 Mar 2012 10:38 PM #7
Sounds like the best solution, thanks!


Reply With Quote