Reputation: 7226
My company's web app maintains sessions via cookies. One of our customers uses MS Edge and wants to be able to have a completely separate session running our web app in each browser tab, for sometimes 2 but up to 3 tabs and 3 separate sessions.
As a workaround, getting 2 different sessions is pretty easy by using 1 normal Edge window + 1 private/incognito window. The 2 sessions are separate and that's what they want. But what if they want 3 tabs and 3 sessions? Is there a way with JavaScript to force the browser (in this case Edge) to not share cookies between tabs, and thus force a separate session in each tab? I'd prefer not to have to rely on Private/Incognito usage, though that is the workaround for now.
Note: This is a .NET webapp and I am aware of the cookieless
setting in web.config - apparently that approach doesn't fully work (I don't yet have the details why), which is why I'm feeling out a possible js approach.
Upvotes: 0
Views: 672
Reputation: 211
As far as I know this is not possible. There is no notion of "sessions" in cookies. Cookies are always browser-wide, shared by all tabs. Even so-called "session cookies" (= cookies which die when the user closes the browser) are browser-wide.
For an alternative, look at the Window.sessionStorage API. This does work the way you need: it creates a separate session for each tab, even if it's the same URL.
Upvotes: 2