Home arrow Apache arrow Page 2 - ASP: Active Sessions, Active Logins and Total Site Hits

ASP: Active Sessions, Active Logins and Total Site Hits

William T explains how to make sure that your site contains a safe and accurate track of genuine page hits.

Author Info:
By: Softwaremaker
Rating: 5 stars5 stars5 stars5 stars5 stars / 59
March 03, 2003
  1. · ASP: Active Sessions, Active Logins and Total Site Hits
  2. · Problem Solved
  3. · Writing The Code
  4. · Active Logins
  5. · Conclusion

print this article

ASP: Active Sessions, Active Logins and Total Site Hits - Problem Solved
(Page 2 of 5 )

Sure you can paste this tracker component on every page on your site, but that would be highly cumbersome, inefficient and inaccurate as that would be lots of double-counting. You also cannot keep track of the active sessions on your site which means the number of visitors to your site at any moment. Moreover, once you update your page, or when the server shuts-down for maintenance, you lose all data and history of your hit counts.

I am sure there are components out there that can do the job but it all depends on the price and whether your remote web administrator allows you to install these components on your virtual server (sharing the server with many websites).

There is a simple and free way to do what is described above via Microsoft Active Server Pages (ASP) which is widely used and implemented and free. Most websites, whether they are running IIS or Apache, support ASP.

All you need to do is to upload this script on this page to your server and you will be able to see a fairly accurate count of hits on your site, not just the page alone.
The scripts provided below MUST be pasted on a text-based file called GLOBAL.ASA.

This file is always read by the server first whenever a browser requests HTTP content from the web server and its therefore accurate as any pages requested by the server will go through the GLOBAL.ASA file first.

The GLOBAL.ASA file is a fairly narrow topic but I will only highlight the 4 events that the GLOBAL.ASA file implements. You can also declare application-wide objects and variables on this file but we will only focus on keeping track of site-hits here.

The events that the GLOBAL.ASA file implements corresponds to the Application and Session Object. They are namely Application_OnStart, Session_OnStart, Session_OnEnd and Application_OnEnd. They are all run in that order.

Application objects are used throughout the application regardless of the users and are started when the web-server starts and ends when the web-server shuts down (or when you copy a newer version of the GLOBAL.ASA file onto it). Session objects, on the other hand, are used per browser session. This means that a new browser, regardless of where it comes from, instantiates a new session. Session objects are cleared and re-initialized when the session times out which in most cases is 10 minutes.

blog comments powered by Disqus

- Programmatically Manipulating Microsoft Exce...
- Installing PHP under Windows
- Compressing Web Content with mod_gzip and mo...
- Compressing Web Output Using mod_deflate and...
- Setting Up Apache 2.0.45 to Parse PHP Pages
- Custom Error 404 Documents with PHP
- Using Apache and PHP on Mac OS X
- ASP: Active Sessions, Active Logins and Tota...
- Working With Oracle on Windows: Part 1
- The Quick-n-Dirty Guide to Setting Up Apache...
- Installing Apache With SSL: The Complete Gui...
- 7 Powerful .htaccess Customization Tips
- Trap And Get Notified: A Practical Solution ...
- One Way To Use Server Side Includes
- Using ForceType For Nicer Page URLs

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials