Abhilash Nagar
asked on
localStorage NULL in new tab
Hello,
I am setting
localStorage.setItem("user Name",user StrName);
which is fine if it is a single tab. But as soon as new tab opens and i call
localStorage.getItem("user Name");
it is null
Not sure why it is null in new tab.
Please suggest.
I am setting
localStorage.setItem("user
which is fine if it is a single tab. But as soon as new tab opens and i call
localStorage.getItem("user
it is null
Not sure why it is null in new tab.
Please suggest.
Are the pages from the same web server?
ASKER
Thanks for the response Brian.
The page which i am setting is in local file system but the page which opens in new tab is hosted in IIS web server.
The page which i am setting is in local file system but the page which opens in new tab is hosted in IIS web server.
retrieval of localStorage from another tab should just working well.
what you could have missed are:
1. the sequence of page loading, make sure you loaded the page that calling localStorage.setItem before localStorage.getItem
2. make sure both pages are refer to the same item, in this case: "userName"
3. make sure in the process of showing userName using localStorage.getItem, value of "userName" is not being overwritten or cleared.
4. make sure you got a modern web browser that support localStorage
what you could have missed are:
1. the sequence of page loading, make sure you loaded the page that calling localStorage.setItem before localStorage.getItem
2. make sure both pages are refer to the same item, in this case: "userName"
3. make sure in the process of showing userName using localStorage.getItem, value of "userName" is not being overwritten or cleared.
4. make sure you got a modern web browser that support localStorage
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you ,really thanks for the response.
Ok sure, so I will then host all the files on IIS and will retry again , I think ,should work after that.
Ok sure, so I will then host all the files on IIS and will retry again , I think ,should work after that.
ASKER
Thanks Brian, as you said i hosted both WEbAPI service and Webapplication , with the same IP address, it worked. Even if there is something like localhost in webapplication URL and in webapi URL it is IPaddress, it was not working. I changed the webapplication to IPaddress rather then localhost so both are same, it started working then.
So you are right, really thanks for your help.
So you are right, really thanks for your help.
ASKER
really thanks for your help.
No problem. Glad to help.