|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Count your Visitors in ASP...
ever wanted to count the number of visitors in asp.....like they do here in PHP??
I have been looking for this solution for a while... and stumbled accross it today.... all you need to do is to add a few lines to the "global.asa" file. I didnt know where mine was, so I made my own global file, and saved it in the root directory. Add this text: <SCRIPT LANGUAGE="VBScript" RUNAT="Server"> Sub Application_OnStart ' Set our user count to 0 when we start the server Application("GuestUsers") = 0 End Sub Sub Session_OnStart ' Change Session Timeout to 10 minutes (or whatever) Session.Timeout = 10 ' Set a Session Start Time ' This is only important to assure we start a session Session("Start") = Now ' Increase the active visitors count when we start the session Application.Lock Application("GuestUsers") = Application("GuestUsers") + 1 Application.UnLock End Sub Sub Session_OnEnd ' Decrease the active visitors count when the session ends. Application.Lock Application("LoggedinUsers") = Application("LoggedinUsers") -1 Application.UnLock End Sub </SCRIPT> then save all that as "global.asa"..... then on your webpage (eg: Index.asp) add this code: Online Users: <%= Application("GuestUsers") %> that's it. The above code will look like: Online Users: 1 or how ever many there are!! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Count your Visitors in ASP... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|