I’m storing some value in an asp.net session on the first page. On the next page, this session value is being read. However if multiple tabs are opened and there are multiple page 1->page 2 navigation going on, the value stored in session gets mixed up since the session is shared between the browser tabs.
I’m wondering what are the options around this :
-
Query String: Passing value between the pages using query string, I don’t want to take this approach since there can be multiple anchor tags on page 1 linking to page 2 and I can not rewrite the URLs of each tag since they are dynamic.
-
Cookies??? In-memory cookies are shared across browser tabs too, same as the session cookie, rite ?
Any other option?
PS: Page 1 to page 2 is not a form submit.
I figured out a solution :
Using Javascript assign a unique id like a guid to the browser window / tab by assigning the guid value to the window.name property. window.name property is unique to each browser window/tab and won’t be shared across the windows.
Using the guid as the key, read and write data to your ASP.NET session via a webservice. Since javascript does not have access to asp.net session, you will need to use a webservice and call it’s method through javascript.
The data can be transfered between javascript and webservice via JSON.