1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    103
    Vote Rating
    10
    Answers
    5
    pepperseb is on a distinguished road

      0  

    Default Answered: LocalStorage - Multiple applications on the same domain issue

    Answered: LocalStorage - Multiple applications on the same domain issue


    Hey Sencha world,
    On the same domain I run my app which is basically an e-commerce app with a shopping cart where items are saved in the localStorage.

    The app takes a company parameter on startup.

    Problem:
    If I run the app as company A, I have some products stored into the localstorage.
    Now, I run the same app as company B (= differents products), I still have the old company A's products referenced in the same localStorage.

    As a result, if I add a product to my shopping cart, I end up with product refs from company A and B which is obviously not acceptable..

    My idea of what's happening:
    The localStorage is shared between the two companies because the app is running on the same domain with the same localStorage identifier. The solution might be to have different localStorage ids for each company.

    But, how can I do it?

    Thanks in advance for any answer.

  2. Make the localstorage proxy id dependent on Company id.



    proxy:{ type:'localstorage', id :'storedProducts-'+companyId}

  3. #2
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    612
    Vote Rating
    26
    Answers
    67
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default


    Make the localstorage proxy id dependent on Company id.



    proxy:{ type:'localstorage', id :'storedProducts-'+companyId}

  4. #3
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    612
    Vote Rating
    26
    Answers
    67
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default


    OR add a filter on store using the LocalStorage, to filter products by company id, but I would go with the previous idea

  5. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    103
    Vote Rating
    10
    Answers
    5
    pepperseb is on a distinguished road

      0  

    Default


    Thank you bluehipy, the first solution works well.

    I thought Sencha would have not recognized my companyId because I loaded it in app's launch function.

Thread Participants: 1

Tags for this Thread