ASP: Active Sessions, Active Logins and Total Site Hits - Conclusion
(Page 5 of 5 )
These are just my way of implementing a counter to keep track of Active Logins on my site. It may not be the most efficient method around so if any of you fellow developers have a better way to implement this, please do not hesitate to email me (itnews@Softwaremaker.Net) and let me know.
My website http://www.Softwaremaker.Net has an implementation of this script. Try it out by refreshing my homepage right away, then refreshing it after 10 minutes when your session times out or try to open up a new browser window to start a new session to see the active sessions and the number of site hits increment then wait for it to time out and watch the active session count decrement.
There is also a counter to keep track the number of active Logins at the current moment so try logging in and watch the active Login Counter increment and then do two different logouts to see the Active Login Counter decrement, one by manually terminating the session by clicking the Logout button and the other by waiting for the session to end after 10 minutes.
As you can see, once you understand the concept of the Application and the Session Object, we can easily manipulate the variables accordingly to what we want. But be careful, the perfect software engineering concept is often a Holy Grail at best. Overuse of the Application object can have undesirable effects on your web application as it will be harder to keep track of what each application variable is storing. It will also result in slower loading and memory leakage if unused application objects are not cleared properly.
Enter ASP.NET and the Garbage Collector to solve these problems. The GLOBAL.ASA file has its own quirks too. Each time the web server is shut down, the GLOBAL.ASA file has to be re-copied back up to its remote location or your site will fail to initialize. But these are topics to be discussed on another day in another forum.
Enjoy.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |