Home arrow PHP arrow The Quickest Way To Count Users Online With PHP
PHP

The Quickest Way To Count Users Online With PHP


We've written more than 1 article on how to count users online, but in this article Elan assures us that he's found the quickest, easiest and most logical method. Take a look and see what you think!

Author Info:
By: Elan Bechor
Rating: 4 stars4 stars4 stars4 stars4 stars / 91
October 04, 2002
TABLE OF CONTENTS:
  1. · The Quickest Way To Count Users Online With PHP
  2. · Advantages and Disadvantages To This Method
  3. · Deconstructing the Script
  4. · Conclusion

print this article
SEARCH DEVARTICLES

The Quickest Way To Count Users Online With PHP
(Page 1 of 4 )

Many websites, especially ones using portal scripts or forums, display how many users are currently visiting the website. Displaying "There are currently 202 visitors online" (the most we’ve ever had online at once here at DevArticles) on your website can impress visitors and potential advertisers. But you must remember, if you're going to try and implement a method of counting visitors, you should strive to do it efficiently. This is why this article was written.

Many articles have been written on the subject of counting visitors, but they all rely on a database that has to be updated every time a user visits a new page. It can become a huge stress on the server (especially MySQL, which doesn't handle write accesses as well as other RMDBS's) if your site receives a lot of visitors. Luckily, there is a more efficient, clean, and faster solution to this problem.

Instead of relying on a database, an alternative method simply counts how many session files there are in the session directory. Because this method never has to read through any files, just their file names, this can take less than a millisecond (seven tenths, to be exact) to complete.

This article assumes that the user has intermediate experience with PHP, and is familiar with the concept of sessions. The server running this script must have PHP 4+ installed, and be compiled with sessions.
blog comments powered by Disqus
PHP ARTICLES

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

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 
Support 

Developer Shed Affiliates

 




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