Hi,
I tried with your provided solution but failed to update record in database and send email automatically on session expire/end or logout.
Protected Sub SignInButton_Click(sender As Object, e As EventArgs) Handles SignInButton.Click
Dim mySelection = "select * from RegisteredCustomers where EmailAddress='" & EmailAddress.Text & "' and Passwords='" & Passwords.Text & "'"
Dim adp As New OleDbDataAdapter(mySelection, cn1)
Dim dt As New DataTable
adp.Fill(dt)
If dt.Rows.Count <> 0 Then
EmailAddress1.Text = (dt.Rows(0).Item("EmailAddress"))
Session("EmailAddress") = EmailAddress1.Text
Session("EmailAddressforEmail") = EmailAddress1.Text
End If
End Sub
Protected Sub LogoutButton_Click(sender As Object, e As EventArgs) Handles LogoutButton.Click
Session.Clear()
Session.Abandon()
Session.Remove("EmailAddress")
'Session.RemoveAll()
Response.Redirect("Home")
End Sub
Global.asax
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
Dim val As [String] = Session("EmailAddressforEmail").ToString()
cn1.Open()
Dim cmd As New OleDb.OleDbCommand("Update RegisteredCustomersLog set LogoutDate = '" & Now.ToLongDateString & "', LogoutTime = '" & Now.ToLongTimeString & "' where EmailAddress = '" & val & "' ", cn1)
cmd.ExecuteNonQuery()
cn1.Close()
SendHTMLMail()
Session.Clear()
Session.Abandon()
Session.RemoveAll()
Session.Remove("EmailAddress")
Session.Remove("EmailAddressforEmail")
End Sub