FREE tutorial,solution,RSS Feeds on Operating Systems, Programming, Web Development, Applications, Databases, Networking, Hardware, Security, SEO Free Expertsforge Membership
Join us as Moderator
Submit Article to Expertsforge.com Submit Article My Expertsforge
 
RSS Feeds, Help Help RSS Feeds
bannertop
 

ASP Tutorial: Active users Hit Counter - Finding Active Users on your Website

jawahar
2/3/2005 4:15:48 AM, Views: 1838
The following code counts how many active users are there are on your site, this is the most widely used code on the internet.

Using a 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
End Sub

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 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 code to a page to count the active users and name the file with .asp extension

<b><%= Session("VisitorID")%></b> visit(s)
<b><%= Application("Active")%></b> visitor online
Next Steps:
Add this Tutorial to:
Blink Blink del.icio.ous Del.icio.us Digg Digg
Fark Fark Furl Furl Google Google
Reddit Reddit Simpy Simpy Spurl Spurl
Technorati Technorati Windows Live Win Live Yahoo Yahoo
Rate Me!
Not Yet Rated!
Rate:
Send Private MessageSend Message
Signup / Login To View the Solution or Provide Comments
Post Comment/Solution
Comment:*
        (Link Rules) 
  Use : [bold] for <b>; [/bold] for </b>; [italic] for <i>; [/italic] for </i>; [code] & [/code] for code
 
Categories
Options
ASP RSS Feed
Most Popular Tutorial
Most Popular Solution
Top Rated
Top Rankers
Overall
1. jawahar (3000)
Yearly -2008
1. jawahar (200)
Expertsforge Sponsors
bnrtop