Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different ASP.NET Session for each browser tab

Is it possible to not share Session variables between different browser tabs?

I want to keep one login session between tabs, but don't want to share information between opened tabs.

is it possible?

like image 223
Vnuuk Avatar asked Jan 24 '18 16:01

Vnuuk


People also ask

How do browser tabs differ sessions?

You can use HTML5 SessionStorage (window. sessionStorage). You will generate a random id and save in session Storage per Browser Tab. Then each browser tab has his own Id.

Are sessions shared between tabs?

Session storage is tab specific and data are not shared between different tabs. Session storage runs in modern browser.

How PHP handle session in multiple tabs in a browser?

To distinguish between tabs you just have to check $_COOKIE['tab_id'] on the server and store sessions values appropriately. Do note that Firefox behaves strangely, in that triggering window. open() will create a window that shares sessionStorage with its parent, giving you two tabs with the same ID.


1 Answers

No. That is not possible with the session cookies, which are controlled by your browser. You have no control whatsoever if the cookies are reused in other tabs (usually they will, but it is possible browser vendors will deviate from that).

You might be looking for 'view state', hidden input fields or similar approaches to let the state travel with the page, instead of the session.

like image 85
Patrick Hofman Avatar answered Oct 05 '22 07:10

Patrick Hofman