|
|
| CURRENT VIEWERS IN ASP |
|
I will in this tutorial show you how to make a script that shows you how many
viewers your site has.
|
Global.asa
|
|
In order to at all time know how many viewers that are viewing your site, I choose to
use the global.asa file. In this file we use the On_Start method for Application and
Session as well as the Session_OnEnd.
|
Sub Application_OnStart
Application("Active")=0
End Sub
Sub Application_OnEnd
'no code is needed here
End Sub
Sub Session_OnStart
Session.Timeout=20
Session("Start")=Now
Application.Lock
Application("Active")=Application("Active")+1
'this adds 1 to the number of active users
'when a new user hits
Application.unlock
End Sub
Sub Session_OnEnd
Application.Lock
Application("Active")=Application("Active")-1
'this subtracts 1 from the number of active users
'when a new user leaves
Application.unlock
End Sub
|
currentusers.asp
|
|
In this file you call the function with the Application("Active") user.
|
Response.Write("There are " & Application("Active"))
Response.Write(" users on this page!")
|
|
Category
|
Programming with ASP
|
|
Author
|
Tommy Johannessen
|
|
|
|