Free Active Visitors Counter (.asp)

With this script we will be able to know and show in our pages the number of active visitors in a given moment. The script has two parts: a file name global.asa (check information on "global.asa" file in this tutorial), and a small code you must insert in your pages to show the number of active users.

Just copy the code in the table to a text file and save it in the main directory of your site ("/global.asa").
 

global.asa
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

Sub Application_OnStart
application("activevisitors")=0
End Sub

Sub Application_OnEnd
End Sub

Sub Session_OnStart
application.lock
application("activevisitors")=application("activevisitors")+1
application.unlock
End Sub

Sub Session_OnEnd
application.lock
application("activevisitors")=application("activevisitors")-1
application.unlock
End Sub

</SCRIPT>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

The first time a visitor gets to our pages, global.asa will be executed, and consequently, application("activevisitors") in line 4 will get a value equal to "0". Immediately (as a new session has started), in line 12, application("activevisitors") will be increased by one. Each time a new visitor gets to our pages application("activevisitors") will be increased by one, and identically, each time a session is finished, this parameter will be reduce by one (line 18).

In case we want to show the number of visitors in our page, we must use this kind of code :

index.asp
There are  <% =application("activevisitors") %> active visitors.



Google






   



MSN Nick Name



More Resources...





Most Viewed Services:
  1. HTML Tutorial
  2. XHTML Tutorial
  3. CSS Tutorial
  4. Javascript Tutorial
  5. DHTML Tutorial
  6. VB Script
  7. TCP/IP Tutorial
  8. ADO Tutorial
  9. MYSQL Tutorial
  10. ASP Tutorial
  11. AJAX Tutorial
  12. CFML Tutorial
  13. PHP Tutorial
  14. WML Tutorial
  15. FLASH Tutorial
  16. XML Tutorial
  17. RSS Tutorial
  18. SQL Tutorial
  19. HTML Articles
  1. Javascript Articles
  2. PHP Articles
  3. SEO Articles
  4. Web Design Articles
  5. SEO Tips
  6. Web Design Tips
  7. Articles
  8. CSS
  9. CSS Tips
  10. HTML Tips
  11. JAVASCRIPT Tips
  12. MYSQL Tips
  13. PHP Tips
  14. Money
  15. Tutorials
  16. Web Hosting



  • Home
  • Web Directory
  • Top Directoriers
  • Webmaster Directories
  • Contact
  • © Copyright 2006-2010 All Rights Reserved By CodeDcode.Com : HTML : RSS : TEXT : XML