I'd like to maintain a session state per browser tab.
Is this easy (or even possible) to do in ASP.NET?
Example: A user hits Ctrl-T in firefox 5 times and visits the site in each tab. I'd like each tab to have its own session state on the server
jsp ), type your name in the input and submit the form. Then open a new tab in the same browser, and then you can see your name (get from the session) on the new tab. Be careful with the browser-cache, sometimes seems that it doesn't happen, but it's in the cache, refresh the second tab. Thanks.
Scenario: By default all browsers share session state between multiple tabs. So if you logged into one tab with particular site and open internal link of the same site in new tab, you need not to worry to login again. It will automatically declare you as logged in user.
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.
To facilitate multi-tab session states for one user without cluttering up the URL, do the following.
In your form load function, include:
If Not IsPostback Then 'Generate a new PageiD' ViewState("_PageID") = (New Random()).Next().ToString() End If
When you save something to your Session State, include the PageID:
Session(ViewState("_PageID").ToString() & "CheckBoxes") = D
Notes:
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