I am relatively new to ASP.NET so please forigve the nubie question!
I am using Session to store user data BUT I am seeing the following:
User1 logs in:
I set the Session["User"] = "user1"
User2 logs in:
I set Session["User"] = "user2"
I thought that Session was specific to the current session but it seems not to be since it seems I am altering the same Session var. I say this because after user2 logs in the Session var changes to Session["User"] = "user2" and anything user1 does is saved
for "user2"??? Certainly I am doing something wrong and maybe misunderstood how to use Session???
No ... that should not be the case. That is the case for the Application or Cache objects.
Make sure that when you are testing this that you don't use the same browser / computer, because even though you may be logged on with a different account, the session may still be shared. Try testing from two seperate computers.
BINGO! sivilian. I was using the same browser on the same machine! Tested on 2 diff machines and it worked fine. Weeeeeeeeeeeew! That scared the fire out of me! Is there a way to safeguard against this behavior on the same machine?
If you want to open different session in the same browser, at least in IE, you can go to the file menu and select New Session. This will open a new window in a new session
Outflank
Member
28 Points
29 Posts
Session question
Dec 16, 2011 03:34 PM|LINK
Hello all:
I am relatively new to ASP.NET so please forigve the nubie question!
I am using Session to store user data BUT I am seeing the following:
User1 logs in:
I set the Session["User"] = "user1"
User2 logs in:
I set Session["User"] = "user2"
I thought that Session was specific to the current session but it seems not to be since it seems I am altering the same Session var. I say this because after user2 logs in the Session var changes to Session["User"] = "user2" and anything user1 does is saved for "user2"??? Certainly I am doing something wrong and maybe misunderstood how to use Session???
Thanks in advance
Marshall
sivilian
Contributor
6235 Points
1194 Posts
Re: Session question
Dec 16, 2011 03:56 PM|LINK
No ... that should not be the case. That is the case for the Application or Cache objects.
Make sure that when you are testing this that you don't use the same browser / computer, because even though you may be logged on with a different account, the session may still be shared. Try testing from two seperate computers.
hope this helps,
sivilian
Outflank
Member
28 Points
29 Posts
Re: Session question
Dec 16, 2011 09:35 PM|LINK
BINGO! sivilian. I was using the same browser on the same machine! Tested on 2 diff machines and it worked fine. Weeeeeeeeeeeew! That scared the fire out of me! Is there a way to safeguard against this behavior on the same machine?
Thanks a ton for you help!
sivilian
Contributor
6235 Points
1194 Posts
Re: Session question
Dec 16, 2011 11:26 PM|LINK
If you want to open different session in the same browser, at least in IE, you can go to the file menu and select New Session. This will open a new window in a new session
sivilian
Outflank
Member
28 Points
29 Posts
Re: Session question
Dec 17, 2011 03:06 PM|LINK
sivilian:
Duh! I should know that! LOL!
You've been a great help!
Thank you
Marshall