Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp.net vb.net session issue with multiple browser tabs

Posted on 2013-05-29
4
Medium Priority
?
1,719 Views
Last Modified: 2013-06-02
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!
0
Comment
Question by:kevinvw1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1000 total points
ID: 39206700
In all other questions here where session id's are stored in cookies, they have discovered that the 'cookie jar' is common to all open windows of a browser.  If you change the value in one window, it changes in ALL windows.  There is no known fix for this problem.  All browsers act this way.  

However... each browser keeps it's Own cookies and does not share them with the other browsers.  So you can open a different browser and not change the session in the first browser.
0
 
LVL 16

Accepted Solution

by:
Stephan earned 1000 total points
ID: 39206710
Like davebaldwin said: a session is persistend in all windows of thesame browser.

The only approach to fix this, is using URL's. If you do webforms you can try viewstate and in mvc try viewdata.
0
 

Author Comment

by:kevinvw1
ID: 39215372
Actually it looks like DOM sessionStorage may help me in this situation.

sessionStorage variables appear to be unique within sessions and within tabs.

Something like this -

if (""+sessionStorage.getItem("id") == "null")
      {      
            var milliseconds = new Date().getTime();
            alert ("Now setting to - " + milliseconds);            
            sessionStorage.setItem("id",milliseconds);
      }
}

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.
0
 
LVL 16

Expert Comment

by:Stephan
ID: 39215393
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
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question