kevinvw1
asked on
asp.net vb.net session issue with multiple browser tabs
I am stepping in to the middle of a very big asp.net/vb.net app project.
The app uses asp.net membership forms authentication to manage users and logins.
The app also uses sessions variables quite a bit to pass data around (no data is passed around in the query string).
The issue is that a user will pull up a record which sets a session variable for the recordid.
Then they will need to jump to another record, but keep the current record open.
So they will open a new browser tab and look up the other record which then changes the session variable.
Then they will go back to the first record and add a child record. But it gets added to the wrong parent record because of the session variable switch.
I have done a whole bunch of google'ing and reading on this, but I can't find an easy fix.
(Yes, I no there may not be an easy fix).
One option would be to prevent them from opening the site in a 2nd tab.
Or at least make sure that it starts a new session if they open in 2nd tab.
I have looked in to this, but haven't found a solution.
Any suggestions would be much appreciated.
Thanks!
The app uses asp.net membership forms authentication to manage users and logins.
The app also uses sessions variables quite a bit to pass data around (no data is passed around in the query string).
The issue is that a user will pull up a record which sets a session variable for the recordid.
Then they will need to jump to another record, but keep the current record open.
So they will open a new browser tab and look up the other record which then changes the session variable.
Then they will go back to the first record and add a child record. But it gets added to the wrong parent record because of the session variable switch.
I have done a whole bunch of google'ing and reading on this, but I can't find an easy fix.
(Yes, I no there may not be an easy fix).
One option would be to prevent them from opening the site in a 2nd tab.
Or at least make sure that it starts a new session if they open in 2nd tab.
I have looked in to this, but haven't found a solution.
Any suggestions would be much appreciated.
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Kevin,
Keep in mind that sessionStorage is not available in all browsers (doesn't work in IE7)
Here is a list of browsers that support and doesn't support sessionStorage:
http://caniuse.com/namevalue-storage
Check out the following polyfill:
https://gist.github.com/tagawa/2880273
Keep in mind that sessionStorage is not available in all browsers (doesn't work in IE7)
Here is a list of browsers that support and doesn't support sessionStorage:
http://caniuse.com/namevalue-storage
Check out the following polyfill:
https://gist.github.com/tagawa/2880273
ASKER
sessionStorage variables appear to be unique within sessions and within tabs.
Something like this -
if (""+sessionStorage.getItem
{
var milliseconds = new Date().getTime();
alert ("Now setting to - " + milliseconds);
sessionStorage.setItem("id
}
}
I just ran a test and even using "Duplicate Tab" gives me a new local id value.
So between cookies and DOM sessionStorage I think I can prevent the user from opening 2nd session (in same browser).
Thanks for your help.