Here is a very simple example.
First, the global.asa
Code:
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
'This is a very simplistic example.
Sub Application_OnStart
' Ths initializes the counter
Application("ONLINE_COUNT") = 0
End Sub
Sub Session_OnStart
' Use whatever timeout you want. This sets it to 1 minutes for test purposes
' so you can easily see the count go down as sessions are ended...
Session.Timeout = 1
' By setting a session variable when we first start a session we make sure that
' a session is actually started.
Session("STARTED") = Now
' Increment that counter that keeps track of users with an active session
Application.Lock
Application("ONLINE_COUNT") = Application("ONLINE_COUNT") + 1
Application.UnLock
End Sub
Sub Session_OnEnd
' Decrease the active visitors count when the session ends.
Application.Lock
Application("ONLINE_COUNT") = Application("ONLINE_COUNT") - 1
Application.UnLock
End Sub
</SCRIPT>
and now a simple page to demonstrate:
Code:
<%
' I named this page ShowCount.asp
function GetCount
s = "The count is: " & Application("ONLINE_COUNT") & "<br/>"
GetCount = s
end function
function GetSessionStart
GetSessionStart = "I signed on at: " & Session("STARTED") & "<br/>"
end function
%>
<html>
<head><title>Count Users Test</title></head>
<body>
<%=GetCount %>
<%=GetSessionStart %>
</body>
</html>
I found an example of what you want here:
http://www.asp101.com/articles/john/...ve_users_2.asp
Woody Z
http://www.learntoprogramnow.com