Writing Your First ASP Application ( Quick Start ) - Removing Users From The List
(Page 7 of 8 )
Now we have a way to add users to the list, and to show the list of users on any web page. But at this point, we have not discussed a way to remove users from our list. Without removing the users, their names would stay on the list forever.
In order to remove users from the list, we will need to utilize the GLOBAL.ASA file. I am not going to go into great detail about the features of this file in this article. One of the features of the GLOBAL.ASA is the ability to recognize when a user’s session ends. This can be from the user choosing an option to logout of the system, or from a system-defined timeout.
Here is the GLOBAL.ASA for this:
<SCRIPT language=vbscript runat="server">
Sub Session_OnEnd
dim conn
dim strsql
‘ Create a SQL statement to insert the name into our table
strsql = "select UserName from UsersOnline”
‘ Open the database using our DSN
strconn = “DSN=UserBase”
set conn = server.createobject("adodb.connection")
conn.open strconn
‘ Use the session variable to delete the user from the table
strsql = “delete from UsersOnline where UserName = “ & chr(39) & _
Session(“UserName”) & chr(39)
conn.execute strsql
conn.close
set conn = nothing
End Sub
As you can see, I used the session variable that was created in the dologin.asp page to delete the user from the table when the session ends.
Next: Additional Enhancements >>
More ASP Articles
More By Rich Smith