Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing Browser Tab information at backend?

Scenario:

We have one analysis which gives different results based on different inputs. So if the user open the same analysis in two different browser tabs, the session variables being common will get overridden and output will be same in both tabs though we want different outputs based on different user inputs in tabs.

So we plan to send a tab-id at the backend so that we save session variables per tab-id.

Is there some automatic way that tab information is being sent to the server like may be in request header or something like that?? Or we will have to generate a tab-id ourselves and send it with every request?

like image 399
Siddharth Trikha Avatar asked Oct 22 '25 19:10

Siddharth Trikha


1 Answers

You'll have to generate your tab-id and pass it back with each request, but the following might make it a bit easier:

You can use sessionStorage from Web Storage API to store values unique to each tab. Every tab in the browser starts a new session so they are always distinct.

https://developer.mozilla.org/en/docs/Web/API/Window/sessionStorage

It should work with most common browsers (even IE8+): http://caniuse.com/#search=web%20storage

Hope that helps!

like image 190
beercohol Avatar answered Oct 25 '25 09:10

beercohol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!