WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this Article to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES SUBMIT AN ARTICLE PRINT
Title : The Quickest Way To Count Users Online With PHP
Categories : PHP, Sessions
devarticles
devarticles
Date : 2003-04-21
Grade : 4 of 5 (graded 1 times)
Viewed : 3191
Search : More Articles by devarticles
Action : Grade This Article
Tools : My Favotite Articles


  Submit your own code examples 
 


Introduction

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.

Read More...









PHP 101 Part 10 of 15 : A Session In The Cookie Jar
Categories : PHP, Beginner Guides, Cookies, Sessions
PHP for Beginners by a Beginner: Simple Login, Logout, and Session Handling
Categories : PHP, Sessions, Authentication
Building a PHP Style Switcher
Categories : PHP, Sessions, Personalization and Membership
Developing Custom PHP Sessions
Categories : PHP, Sessions
Exploring Session Security In PHP Web Applications
Categories : PHP, Security, Sessions, Web Applications
Working with Dates and Times in PHP
Categories : PHP, Date Time
10 PHP Functions I Bet You Didn't Know About!
Categories : PHP, PHP Functions, Filesystem, Arrays, Errors and Logging
Using the .NET Assembly in PHP
Categories : PHP, .NET
Date Arithmetic With MySQL
Categories : PHP, Databases, MySQL, Date Time
Saving Images in MySQL
Categories : MySQL, PHP, Graphics, Databases
PHP References Explained
Categories : PHP References, PHP
Aspect-Oriented Programming and PHP
Categories : PHP, Aspect Oriented Programming
Beginners guide to PHP and MySQL
Categories : PHP, Beginner Guides, Databases, MySQL, Installation
Logging with PHP
Categories : PHP, Log Files
Who's Linking?
Categories : PHP, Beginner Guides, To PHP