11 Aug 2012 3:17 PM #1
Unanswered: Please help!!!! Cannot save user login data to localStorage
I have a "Home" view extends Dataview, and a "Login" view extends form.Panel. In home view, there is a store with url = "http://localhost/getInfo.php?userID=" + localStorage.getItem('userID')
When user login, I save the UserID to localstorage, remove the login view, and add this home view.
The problem I have right now is, there won't be any value returned from localStorage.getItem('userID') for the first time login, and will return the userID of the first user when the second user log in later.
I guess this problem is caused by the order of creating classes.
In my code, the order is: setItem('userID', id) -> Ext.create('Main') -> Ext.destory('Login')
Could anyone provide a suggestion of what may caused this problem and maybe how to solve it?
Thanks in advance!
Best best regards
17 Aug 2012 11:51 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
What is the problem? If getItem doesn't return something then create the Login view. If it does then create the Main view.Mitchell Simoens @LikelyMitch
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
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 firstname.lastname@example.org
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!
When posting code, please use BBCode's CODE tags.
17 Aug 2012 7:15 PM #3
Thank you. I found the answer from your other reply. Initially, I set autoload to true, which let the store load resources before I add extraparams in the url. So, the solution is to set autoload to false, and use setUrl() method when I get response back from the server.