Hi Mark,
1. Using SQL.
2. I am as sure as I can be. See script below
3. I'm assuming it will occur when it times out.
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
common.SessionLog(3)
End Sub
Public Shared Function SessionLog(ByVal LogType As Integer)
Dim ID As String = ""
Dim Parts As String = ""
Dim SessionID As String = ""
Dim customer As String = ""
Dim email As String = ""
Dim uniSession As UniSession = Nothing
Try
Select Case LogType
Case 1
' Application Start
email = "admin"
ID = LogType & "_AppStart_" & IConvD2(Now) & "_" &
IConvMTS(Now) & "_" & CompanyCode
Case 2
' Session Start
SessionID = Current.Session.SessionID.ToString
ID = LogType & "_SessStart_" & SessionID & "_" &
IConvD2(Now) & "_" & IConvMTS(Now) & "_" & CompanyCode
Case 3
' Session End
SessionID = Current.Session.SessionID.ToString
customer = Current.Session("CustomerNum")
email = Current.Session("CustomerEmail")
Dim bag As ArrayList = Current.Session("ShoppingBag")
For Each i As BagItem In bag
Parts &= i.PartNo & "-" & i.Name & " :: "
Next
ID = LogType & "_SessEnd_" & SessionID & "_" &
IConvD2(Now) & "_" & IConvMTS(Now) & "_" & CompanyCode
Case 4
' Application End
email = "admin"
ID = LogType & "_AppEnd_" & IConvD2(Now) & "_" &
IConvMTS(Now) & "_" & CompanyCode
End Select
uniSession = UOOpenSession()
Dim uf As UniFile = uniSession.CreateUniFile("BAG")
With uf
.RecordID = ID
.WriteField(1, Now)
.WriteField(2, Current.Session.SessionID)
.WriteField(3, CompanyCode)
.WriteField(4, Parts)
.WriteField(5, Current.Session("CustomerEmail"))
.WriteField(6, customer)
.Close()
End With
Return True
Catch ex As Exception
UOCloseSession(uniSession)
Dim msg As New MailMessage
msg.From = New
MailAddress(ConfigurationManager.AppSettings("ErrorEmailFrom"))
Dim toEmails() As String =
ConfigurationManager.AppSettings("ErrorEmailTo").Split(";")
For i As Integer = 0 To toEmails.Length - 1
msg.To.Add(toEmails(i))
Next
msg.Subject = "Error on " &
Current.Request.ServerVariables("SERVER_NAME") & " Website"
msg.IsBodyHtml = True
msg.Body = "<font face=verdana size='2'><b>Error on " &
Current.Request.ServerVariables("SERVER_NAME") & " Website!</b><br>" & Now()
& "<BR><br>" & _
"<b>Page Name:</b>common.vb<br>" & _
"<b>URL:</b>" &
Current.Request.ServerVariables("URL") & "<br>" & _
"<b>Function Name:</b> SessionLog<br><br>" & _
"<b>Error Message:</b> " & ex.ToString
Dim smtpClient As New SmtpClient
smtpClient.Host = ConfigurationManager.AppSettings("SMTPServer")
smtpClient.Send(msg)
Return False
Finally
UOCloseSession(uniSession)
End Try
End Function