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?
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.
Session storage is tab specific and data are not shared between different tabs. Session storage runs in modern 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With