1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    11
    Vote Rating
    0
    senchafan12 is on a distinguished road

      0  

    Default Unanswered: Please help!!!! Cannot save user login data to localStorage

    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

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,004
    Answers
    3490
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    11
    Vote Rating
    0
    senchafan12 is on a distinguished road

      0  

    Default


    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.

Thread Participants: 1