About
Download
Pricing/Purchase Info
Highlights
FAQ
How-To
Tutorials
Learn ASP Express
Tech Support
Bug Report
Hosting
Resources
Home
Forums

Peace - Now and Forever
ASP Express
The WEB Professional's Choice
ASP Express Home | What You Get | Pricing Information

New-->Online User Count
Using DatePart and other Date Functions
Understanding Includes
(Updated) Using Variables, Single & DoubleQuotes with SQL Statements in ASP
(Updated) Emailing Form Results
Mass Emailing with CDO
Using The Ad Rotator
ASCII Character Set 0-127
Online User Count
Online User Count

Many people have asked me how I arrive at my 'Users Online' count. Actually, it's very easy and it's all based in the Global.asa file. The coding necessary is shown below, with comments:

SUB Application_OnStart
	' Set our user count to 0 when we start the server 
	Application("ActiveUsers") = 0
END SUB

SUB Session_OnStart
	' Change Session Timeout differently (minutes) if you need to -  default is 20 minutes
	'Session.Timeout = 10 
	' Set a Session Start Time - This is really only important to make sure we start a session 
	Session("Start") = Now 
	' Increase the active visitors count when we start the session 
	Application.Lock 
	Application("ActiveUsers") = Application("ActiveUsers") + 1 
	Application.UnLock
END SUB

Sub Session_OnEnd
	' Decrease the active visitors count when the session ends. 
	Application.Lock 
	Application("ActiveUsers") = Application("ActiveUsers") - 1
	Application.UnLock
END SUB

Then - wherever you want to show this data -
<%
strNumber=Application("ActiveUsers")
response.write (strNumber)
%>
Currently Online


See how simple it is - just include the coding in your Global.asa as shown, and reflect the number in any way you'd like using the response.write statement.


Back to the Top | Tutorials Home | ASP Express Home

Send your comments, questions or suggestions via E-Mail to : (suggestions@aspexpress.com)