Forums

This topic is locked

Users Online.

Posted 05 Jul 2002 04:04:07
1
has voted
05 Jul 2002 04:04:07 aegis kleais posted:
Ok, so how's it done? I'm assuming it's an Application Variable, with code like:

Application.Lock
Application("UsersOnline" = Application("UsersOnline" + 1
Application.Unlock

However this in it's most simplistic for works better as a page counter. Is this where you would use Session_onStart and Session_onEnd functions? What would a sample code be?

These OnStart and OnEnd......are they part of the Global.asa file?

Replies

Replied 13 Jul 2002 05:34:39
13 Jul 2002 05:34:39 aegis kleais replied:
By all means after you've LEARNED how to do something inside and out, get the extension! The only problem is that most extensions are not as customizable as they should be. Some are even known to crash UltraDEV and force a reinstallation. Would be nice if I could export my profile settings for UltraDEV in that case.

Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Replied 13 Jul 2002 13:55:51
13 Jul 2002 13:55:51 Dave Clarke replied:
hi
got some new code which accounts for session timeout delay(got it from aspin.com)
This was in vbscript and i'm using javascript so had to put a few runat=server's in, but works ok as an include file

<b>&lt;script language=vbscript runat=server&gt;
Sub LogActiveUser
Dim strActiveUserList
Dim intUserStart, intUserEnd
Dim strUser
Dim strDate

strActiveUserList = Application("ActiveUserList"

If Instr(1, strActiveUserList, Session.SessionID) &gt; 0 Then
Application.Lock
intUserStart = Instr(1, strActiveUserList, Session.SessionID)
intUserEnd = Instr(intUserStart, strActiveUserList, "|"
strUser = Mid(strActiveUserList, intUserStart, intUserEnd - intUserStart)
strActiveUserList = Replace(strActiveUserList, strUser, Session.SessionID & ":" & Now())
Application("ActiveUserList" = strActiveUserList
Application.UnLock
Else
Application.Lock
Application("ActiveUsers" = CInt(Application("ActiveUsers") + 1
Application("ActiveUserList" = Application("ActiveUserList" & Session.SessionID & ":" & Now() & "|"
Application.UnLock
End If
End Sub

Sub ActiveUserCleanup
Dim ix
Dim intUsers
Dim strActiveUserList
Dim aActiveUsers
Dim intActiveUserCleanupTime
Dim intActiveUserTimeout

intActiveUserCleanupTime = 1 'In minutes, how often should the ActiveUserList be cleaned up.
intActiveUserTimeout = 20 'In minutes, how long before a User is considered Inactive and is deleted from ActiveUserList

If Application("ActiveUserList" = "" Then Exit Sub

If DateDiff("n", Application("ActiveUsersLastCleanup", Now()) &gt; intActiveUserCleanupTime Then

Application.Lock
Application("ActiveUsersLastCleanup" = Now()
Application.Unlock

intUsers = 0
strActiveUserList = Application("ActiveUserList"
strActiveUserList = Left(strActiveUserList, Len(strActiveUserList) - 1)

aActiveUsers = Split(strActiveUserList, "|"

For ix = 0 To UBound(aActiveUsers)
If DateDiff("n", Mid(aActiveUsers(ix), Instr(1, aActiveUsers(ix), ":" + 1, Len(aActiveUsers(ix))), Now()) &gt; intActiveUserTimeout Then
aActiveUsers(ix) = "XXXX"
Else
intUsers = intUsers + 1
End If
Next

strActiveUserList = Join(aActiveUsers, "|" & "|"
strActiveUserList = Replace(strActiveUserList, "XXXX|", ""

Application.Lock
Application("ActiveUserList" = strActiveUserList
Application("ActiveUsers" = intUsers
Application.UnLock

End If

End Sub
&lt;/script&gt;</b>

then the code to call it is

<b>&lt;script language=vbscript runat=server&gt;
Call LogActiveUser()
Call ActiveUserCleanup()

Response.Write "There are " & Application("ActiveUsers" & " active users currently online."

&lt;/script&gt;</b>

this also works fine but writes in top left corner of page, i now need to figure out how to make it write where i want it, i have iserted the code in the page where i want it to write but to no avail, still writes in top left.

Dave

Replied 13 Jul 2002 14:01:22
13 Jul 2002 14:01:22 Dave Clarke replied:
Duh!!!!

Took out the response.write and just left the calls to the subs, then use the application variable from data bindings panel, to put it where i want.
now shows up ok.

Dave
Replied 08 Oct 2002 22:56:47
08 Oct 2002 22:56:47 Tore Woodall replied:
In the code that you provided above in VBSCRIPT, is it also possible to call a list of the user names from this code? I am trying to show the names of the employees logged in doing data entry at any given time and have been using a database query that is not foolproof. Are there any suggestions on getting the actual list of live session variables which can be viewed either as a straight text file or as a real list? Thanks. Tore

Replied 10 Oct 2002 07:47:40
10 Oct 2002 07:47:40 Dave Clarke replied:
beyond me i'm afraid but i'm sure someone will be able to help you

Dave

ASP/VBScript/IIS5.1/WinXPPro & WinXPHome
Replied 10 Oct 2002 11:47:14
10 Oct 2002 11:47:14 Tore Woodall replied:
Thanks Dave, for your response. I hope that someone else does have the answer. It seems so simple a request, to be able to pull up a list of all existing instances of MM_username and diplay that list on a status page, but it really is not simple.

Reply to this topic