The following code counts how many active users are there are on your site, this is the most widely used code on the internet.
Using a text editor create the file global.asa and enter the code below :
<SCRIPT LANGUAGE=VBScript RUNAT = Server>
Sub Application_OnStart
Application("visits")=0
Application("Active")=0
End Sub
Sub Application_OnEnd
End Sub
Sub Session_OnStart
set timeout to 20 mins
Session.Timeout = 20
Session("Start") = Now
increase count by 1
Application.lock
Application("visits") = Application("visits") + 1
intTotal_visitors = Application("visits")
Application.unlock
Session("VisitorID") = intTotal_visitors
Application.lock
Application("Active") = Application("Active") + 1
Application.unlock
End Sub Sub
Session_OnEnd
decrease by 1 when session ends
Application.lock
Application("Active") = Application("Active") - 1
Application.unlock
End Sub
</script>
Now add the following code to a page to count the active users and name the file with .asp extension
<b><%= Session("VisitorID")%></b> visit(s)
<b><%= Application("Active")%></b> visitor online