Last post Jun 28, 2011 09:30 AM by Gaspard
Jun 27, 2011 10:54 AM|Ann03|LINK
I am running into a strange problem I am using the session Object , each time when user login, I am storing the users email, first name, company id and other relevant details into the session. Now the problem is if two different users login to the same
application and accessing the same page, some how the session of one user is getting overwritten by the other user.
My application is an online order submission system, at the end of the process, system update the database with the other persons name. (I am using the session("FullName") inorder to update the database.
Can anyone help me on this problem?
Thanks in advance,
Jun 27, 2011 11:52 AM|kedarrkulkarni|LINK
do u mean.... u r accessing same application with two user names in same browser window?
if u login to application in first tab of IE and then login in same application in another tab of same IE window, session of last logged in user overwrites that of first user...
or u r trying to say that if 2 users from diffrent machine are logging in application and their session getting overwritten?
what is session type u r using?
Jun 27, 2011 12:10 PM|Ann03|LINK
Sorry for the confusion, My problem is when two users accessing the same application(same page) from two different machines, the session getting overwritten. (NOT the different tab of same IE). Also this does not happen all the time, rarely it happens.
I am using the session mode "InProc". Hope this helps!
Jun 27, 2011 12:19 PM|kedarrkulkarni|LINK
if u r using web garden or web farm, then dont use "in proc" session instead use state server...
also, make sure that u r not storing session value in some static variable... (as it will be shared between all instances)
if possible, post the code of functions/events where u r stroing value in session and retriving from session
Jun 27, 2011 12:22 PM|msdnphani|LINK
this should not happen ideally .. could u show us ur code ..
Jun 27, 2011 12:53 PM|Ann03|LINK
I am working on the code that was previously written by somebody. Anyway below are the code details
I am retrieving the values from database and storing them to session
Dim oUsrInfo As New LoggedInUser(Convert.ToInt32(UserDataRow(UserDataset.FLD_idLogin)), _
MySession("oUsrInfo") = oUsrInfo
Content of LoggedInUser Class is as follows
Public Class LoggedInUser
Private _idLogin As Int32
Private _sFullName As String
Private _idCompany As Int32
Public Sub New(ByVal idLogin As Int32, ByVal sFullName As String, _
ByVal idCompany As Int32)
_idLogin = idLogin
_sFullName = sFullName
_idCompany = idCompany
Public Property LoginID() As Int32
Set(ByVal Value As Int32)
_idLogin = Value
Public Property FullName() As String
Set(ByVal Value As String)
_sFullName = Value
Public Property CompanyID() As Int32
Set(ByVal Value As Int32)
_idCompany = Value
Now I am accessing the session as follows
If Not MySession("oUsrInfo") Is Nothing Then
oUsrInfo = MySession("oUsrInfo")
Dim LoginID as string= oUsrInfo.LoginID
Dim UserName as string= oUsrInfo.FullName
Dim CompanyId as string= oUsrInfo.CompanyID
Jun 27, 2011 01:21 PM|kedarrkulkarni|LINK
is class LoggedInUser is shared? how it is decalred?
Jun 27, 2011 01:51 PM|Ann03|LINK
Class LoggedInUser not shared, it is declared as public
Jun 28, 2011 03:40 AM|GPankaj|LINK
Session objects user specific and one user session won't be overriden, else it will defeat the purpose for which it is being built. There is a chance that somewhere the session is referring to static or shared valriable and this is causing the issue. Do
you see any pattern as when it is getting overwritten. What is the memory of the web server?
Jun 28, 2011 09:30 AM|Gaspard|LINK
The best way is to debug your application to check what is going on when you are setting values in Session Object.