|
|
|
|
|
|
| |
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 | |
| |
|
|