Authenticating user identities in ASP applications (5)

Source: Internet
Author: User
Tags array exit
V. End of Session

When the ASP session ends, the Session_OnEnd method in Global.asa is run and can be removed here
A user saved in an array of application ("Users") that was terminated by timeout. Record user is by
It is often useful to terminate a session for any reason (timeout or explicit exit), and the following code updates the users
The TimedOut field for the table implements this feature:
Sub Session_OnEnd
Dim appusers
Dim auser
Dim I
Dim j
Dim conn
Dim supportscookies
Dim founduser
On Error Resume Next
Supportscookies=session ("Supportscookies")
Application.Lock
Appusers = Application ("Users")
Founduser = False
For I = 0 To UBound (appusers)
Set auser = Appusers (I)
If Supportscookies Then
If Auser ("SessionID") = Session.SessionID Then
Founduser = True
End If
ElseIf DateAdd ("n", Session.Timeout, Auser ("LastActivity")) < Now ()
Then
Founduser = True
End If
If Founduser Then
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Connectionstring=session ("ConnectionString")
Conn. Connectiontimeout=session ("ConnectionTimeout")
Conn.mode=session ("mode")
Conn.Open
Conn.execute "UPDATE Users SET timedout=1 WHERE users.signon= '" &
Auser ("Signon") & "'"
Conn.close
Set conn=nothing
Set auser=nothing
Set Appusers (I) = Nothing
For j = I To UBound (appusers)-1
Set Appusers (j) = Appusers (j + 1)
Next
If UBound (appusers) > 0 Then
ReDim Preserve Appusers (UBound (appusers)-1)
Else
Appusers = Array ()
End If
Exit For
End If
Next
Application ("Users") = Appusers
Application.UnLock
End Sub


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.