asptoday_discuss thread: Furthering the Active users to Actual users in the Global.asa
I run a small website I developed for my old school, there are less then
400 members and probably no more the 10 people on the site at anyone time.
many of the users have requested that it would be a good idea to be able
to see who else is currently on the site.
Bearing in mind that when they sign in a cookie is set holding details
like name email etc how would I go about retrieving a cookie opening a
session for the duration that that user is on the site.
I thought about using a global.asa with a timeout of three mintues or
something of inactivity I have almost got there by using a string but it
was suggested that I would be better off using arrays.
This is the story so far: using the string method
Sub Application_OnStart
Session.Timeout = 1
Application.Lock
Application("name") = ""
Application.UnLock
End Sub
Sub Session_OnStart
Application.Lock
Application("name") = Application("name") & Session.SessionID & "," &
Request.Cookies("Name")
Application.UnLock
End Sub
Sub Session_OnEnd
If InStr(Application("name"), Session.SessionID) > 0 Then
Then basically find the starting point of the sessionID and the ending
point of the name then do a replace changing the details for ""
End Sub
Then I thought of the array and version and thought I could do
x = 0 in the application_onstart
then in the session_onstart have something like
UserArray (x,0) = SessionID
UserArray (x,1) = First Name
UserArray (x,2) = Last Name
x = x + 1
Then in the On_End
bFound = False
for i = 0 to UBound(UserArray)
if (UserArray(i) = Session.SessionID) then
UserArray(i) = UserArray(UBound(UserArray))
bFound = True
end if
next
if (True = bFound) then redim preserve UserArray(UBound(UserArray) -1)
I keep getting type mismatch errors on UserArray (x,0) = SessionID and I
am sure I x is supposed to be an Application Variable
Any help on my syntax would be greatly appreciated
Thanks