Session Problems

  • Thread starter Thread starter Gerard
  • Start date Start date
G

Gerard

Dear sir or madam,

I have the problem to our web application using asp.net 2.0. The
problem is that when user A login and then user B login, user A
creates an item and saved. However, the item's created by and updated
by are mentioned that it is created by user B!!!


I think there is some mess up with the session problem. User A's
session has been overwrited by user B. My session state is
<sessionState
  mode="InProc"
  cookieless="false"
  timeout="60"
/>

-- Login Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Template.SetSmartPage(Me)
Template.SetKeyCodeEvent(Me.txt_UserID, KeyMode.ToUpperCase)

If Not Me.IsPostBack Then
Template.SetInitialFocus(Me.txt_UserID)

userProfile = New UserProfile()

If Not Session("userProfile") Is Nothing Then
Session.Add("userProfile", userProfile)
Else
Session("userProfile") = userProfile
End If
'Session("userProfile") = userProfile
Else
'
End If
End Sub

--USER PROFILE
Imports System.Data
Imports System.Data.OracleClient
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Configuration
Imports Microsoft.VisualBasic
Imports CustomApplication.DB

Public Class UserProfile
Public Enum LogType
Login = 1
Logout = 2
End Enum

Public Enum BoolType
NotSet = -1
No = 0
Yes = 1
End Enum

Private Shared lngSessionID As Long
Private Shared strUserName As String
Private Shared strUserFullNameEN As String
Private Shared strUserFullNameCN As String
Private Shared strUserGroupID As String
Private Shared strDistOfficeCode As String
Private Shared bltUpdateOtherDistrict As BoolType
Private Shared bltEnquiryOtherDistrict As BoolType
Private Shared strLoginIPAddr As String
Private Shared strLoginDatetime As String
Private Shared strLogoutDatetime As String

'Profile Management sub functions
Public Property SessionID() As Long
Get
SessionID = lngSessionID
End Get
Set(ByVal value As Long)
lngSessionID = value
End Set
End Property

Public Property UserName() As String
Get
UserName = strUserName
End Get
Set(ByVal value As String)
strUserName = value
End Set
End Property

Public Property UserFullNameEN() As String
Get
UserFullNameEN = strUserFullNameEN
End Get
Set(ByVal value As String)
strUserFullNameEN = value
End Set
End Property

Public Property UserFullNameCN() As String
Get
UserFullNameCN = strUserFullNameCN
End Get
Set(ByVal value As String)
strUserFullNameCN = value
End Set
End Property

Public Property UserGroupID() As String
Get
UserGroupID = strUserGroupID
End Get
Set(ByVal value As String)
strUserGroupID = value
End Set
End Property

Public Property DistOfficeCode() As String
Get
DistOfficeCode = strDistOfficeCode
End Get
Set(ByVal value As String)
strDistOfficeCode = value
End Set
End Property

Public Property AllowUpdateOtherDistrict() As BoolType
Get
AllowUpdateOtherDistrict = bltUpdateOtherDistrict
End Get
Set(ByVal value As BoolType)
bltUpdateOtherDistrict = value
End Set
End Property

Public Property AllowEnquiryOtherDistrict() As BoolType
Get
AllowEnquiryOtherDistrict = bltEnquiryOtherDistrict
End Get
Set(ByVal value As BoolType)
bltEnquiryOtherDistrict = value
End Set
End Property

Public Property LoginIPAddr() As String
Get
LoginIPAddr = strLoginIPAddr
End Get
Set(ByVal value As String)
strLoginIPAddr = value
End Set
End Property

Public Property LoginDatetime() As String
Get
LoginDatetime = strLoginDatetime
End Get
Set(ByVal value As String)
strLoginDatetime = value
End Set
End Property

Public Property LogoutDatetime() As String
Get
LogoutDatetime = strLogoutDatetime
End Get
Set(ByVal value As String)
strLogoutDatetime = value
End Set
End Property

Public Function LogUserAction(Optional ByVal l_Type As LogType =
LogType.Login) As Boolean
Dim blnSuccess As Boolean = False
Dim pa_Data As OracleParameterCollection

Try
pa_Data = New OracleParameterCollection()

pa_Data.Add("out_log_datetime", OracleType.VarChar, 20)
pa_Data("out_log_datetime").Direction =
ParameterDirection.Output

pa_Data.Add("io_session_id", OracleType.Number, 10)
pa_Data("io_session_id").Direction =
ParameterDirection.InputOutput
pa_Data("io_session_id").Value = lngSessionID

pa_Data.Add("in_user_id", OracleType.VarChar, 12)
pa_Data("in_user_id").Direction = ParameterDirection.Input
pa_Data("in_user_id").Value = strUserName

pa_Data.Add("in_login_ip_addr", OracleType.VarChar, 15)
pa_Data("in_login_ip_addr").Direction =
ParameterDirection.Input
pa_Data("in_login_ip_addr").Value = strLoginIPAddr

pa_Data.Add("in_log_type", OracleType.VarChar, 1)
pa_Data("in_log_type").Direction =
ParameterDirection.Input
pa_Data("in_log_type").Value = IIf(l_Type = LogType.Login,
"I", IIf(l_Type = LogType.Logout, "O", "I"))

pa_Data.Add("ret_Value", OracleType.VarChar, 1)
pa_Data("ret_Value").Direction =
ParameterDirection.ReturnValue

clsSttstwDB.ExecuteSql("upkg_stt_usr_log.fn_user_log",
CmdExecType.NonQuery, pa_Data, Nothing)

'Store Information
Select Case l_Type
Case LogType.Login
'Login
lngSessionID = pa_Data("io_session_id").Value
strLoginDatetime = pa_Data
("out_log_datetime").Value
Case LogType.Logout
'Logout
strLogoutDatetime = pa_Data
("out_log_datetime").Value
End Select

blnSuccess = (pa_Data("ret_Value").Value = "1")
Catch exLog As Exception
'
End Try

LogUserAction = blnSuccess
End Function

Public Sub New()
'Initialize values
lngSessionID = -1
strUserName = ""
strUserFullNameEN = ""
strUserFullNameCN = ""
strUserGroupID = ""
strDistOfficeCode = ""
bltUpdateOtherDistrict = BoolType.NotSet
bltEnquiryOtherDistrict = BoolType.NotSet
strLoginDatetime = ""
strLogoutDatetime = ""
End Sub

Protected Overrides Sub Finalize()
'
MyBase.Finalize()
End Sub
End Class


Would it be the Private Shared problem? Does anyone can help me with
this ?? Thanks in advance!
 
coding error on your part. you store your data in shared variables, thus
the data is shared across all requests. request 2 overwrites request 1.

-- bruce (sqlwork.com)
 
Tjx mate. Spotted out !!
coding error on your part. you store your data in shared variables, thus
the data is shared across all requests. request 2 overwrites request 1.

-- bruce (sqlwork.com)








































- Show quoted text -
 
Back
Top