Categories

Subscribe via Email

Enter your email address to subscribe and receive notifications of new content by email.

aspactiveusers

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
Sub 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

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

FacebookTwitterGoogle+PinterestTumblrStumbleUponRedditLinkedInWhatsAppBibSonomyDeliciousDiggDiigoSina WeiboWordPressBlogger PostShare

2 comments to aspactiveusers

Leave a Reply

  

  

  


*

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>