programmingsite : code , tutorials and scripts

 
 
 

Main Menu

home


ASP
ASP.net
C
C++
C#
PHP
Java
JavaScript
Powershell
VB.net

Visual Basic


Resources
wwwstores

beginners php
programmershelp
programmingsite
software directory
Low Cost domains
Mobile phone business
Joke site
Shopping



 

This code snippet shows how to show how many active users there are on your site , this is quite widely used on the internet.

using your favorite 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 SubSub 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 to a page to count the active users

<b><%= Session("VisitorID")%></b> visit(s)
<b><%= Application("Active")%></b> visitor online

If you look below you can see this in action





 
programmingsite