WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 : 3 of 5 (graded 2 times)
Viewed : 5379
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 weve 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...









Building a PHP Style Switcher
Categories : PHP, Sessions, Personalization and Membership
Exploring Session Security In PHP Web Applications
Categories : PHP, Security, Sessions, Web Applications
PHP 101 Part 10 of 15 : A Session In The Cookie Jar
Categories : PHP, Beginner Guides, Cookies, Sessions
Developing Custom PHP Sessions
Categories : PHP, Sessions
PHP for Beginners by a Beginner: Simple Login, Logout, and Session Handling
Categories : PHP, Sessions, Authentication
Sockets and PHP
Categories : PHP, Sockets
PHP and PostgreSQL
Categories : PHP, Databases, PostgreSQL
Static HTML Generation With PHP
Categories : PHP, HTML and PHP
Array Manipulation With PHP
Categories : PHP, Arrays
Date Arithmetic With MySQL
Categories : PHP, Databases, MySQL, Date Time
Executing SQL Server Stored Procedures With PHP
Categories : PHP, Databases, MS SQL Server
Time Is Money Part 1 of 2 - Designing and implementing a Web-based application
Categories : PHP, Databases, MySQL, Complete Programs
Using the .NET Assembly in PHP
Categories : PHP, .NET
PHP Debugging Tutorial
Categories : PHP, Debugging
Keep your Banner Waving
Categories : PHP, PHP Functions, Miscellaneous, Site Planning, Utilities