Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've recently been developing a website using asp.net webforms that uses in proc sessions and I noticed that session ids are shared amongst browser tabs. So I was wondering what you would do for the following situations:

Problem: Multiple logins with different users in the one browser problem

User opens browser tab 1, logins with "user1" - store in session
User opens browser tab 2, logins with "user2" - store in session
At this stage session information is now pointing to "user2" because of how session id is shared amongst browser tabs
User tries an action on tab 1 and suddenly they have "user2" information
How do you alert the user in tab 1 that the user has changed or how do force tab1 user to logout?



Appreciate anyone letting me know of any alternatives or best practices for the above problem
Posted

One alternative would be using the cookie less session where in the session ID is sent in the URL for individual browser requests. So 2 concurrent users will be allowed to use the application in different tabs.

If you are sure of logging out the user 1 since user 2 has logged in, then one way is that you can maintain a mapping table of users and the asp.net session ID. The moment user 2 logs in, the session ID of user 1 will be replaced with user 2's session ID and a comparison in mapping table will reveal that user 1 must be logged out.
 
Share this answer
 
You have to understand that Session values are stored in the server code not in the browser..

so all the tabs will be having the last updated session values...

add a condition that, if session is not null then dont allow to create a new instance of session.

Thanks.
karthik
 
Share this answer
 
This is very much similar to "Switch Account"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900