Global.asa and current users counter

R

Raymondo

Hi, I would like to display the number of current users currently using my
website. I tried the following script in global.asa which works a treat
but..... gives an "error in your global.asa" error in my database DRW. Is
there a secret to running 2 scripts or 2 sub applications_on start? Should I
insertit within the existing script? I tried most of these options but still
get the error. Any ideas gratefully received::

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
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 to 20 minutes (if you need to)
Session.Timeout = 20
' 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("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
</SCRIPT>
 
M

MD Websunlimited

Hi,

You can only have a single global.asa file per application and it may only contain a sing OnStart subroutine. You'll need to take
the script and merge it into the one created by the DRW.
 
R

Raymondo

Hi Mike, thanks for the prompt reply so.....

If I paste the code:

[' Set our user count to 0 when we start the server
Application("ActiveUsers") = 37
End Sub
Sub Session_OnStart
' Change Session Timeout to 20 minutes (if you need to)
Session.Timeout = 20
' 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("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]

within the existing on start routine, does it matter if it is before or
after the Frontpage Generated startspan-endspan? - Cos i thought I had tried
this but still got the error.

Raye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top