PHP Classes
elePHPant
Icontem

PHP Session Count Online Users: Get the number of users that are online in a site

Recommend this page to a friend!
  Info   View files Documentation   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-11-14 (21 hours ago) RSS 2.0 feedStarStarStarStar 61%Total: 457 This week: 245All time: 5,956 This week: 1Up
Version License PHP version Categories
online 1.0.3GNU General Publi...5PHP 5, User Management
Description Author

This class can get the number of users that are online in a site.

It can traverse the directory where PHP saves user session data to find the currently active sessions.

The class returns the number of users that have accessed the current site for the last 3 seconds.

Innovation Award
PHP Programming Innovation award nominee
October 2018
Nominee
Vote
Many PHP applications use sessions to keep track about the users that access a site.

This class provides a means to count the number of active users on a site by accessing session tracking files and counting the active sessions based on the last time a session file for an user was modified.

Manuel Lemos
Name: John S. <contact>
Classes: 1 package by
Country: Indonesia Indonesia
Innovation award
Innovation award
Nominee: 1x

Details

About

Every online counter need a database, This class will not use a database, SQL or NoSQL or even flat-file. It will use PHP session file located in php.ini session.save_path or session_save_path();

Usage

require_once 'online.php';
echo online::who();

It will return integer of total number of online users from last IDLE TIME ago.

Tip

  • To change IDLE TIME you can set MAX_IDLE_TIME to your preferred interval
  • In order to get more accurate number, you need to edit at least one of session key value pair in every page visit
  • In shared hosting environment, session.save_path need to be changed, do not use default path, because it returns a count of all sessions on the server for all sites
  Files folder image Files  
File Role Description
Plain text file online.php Class online class
Accessible without login Plain text file readme.md Doc. Read Me Documentation

 Version Control Unique User Downloads Download Rankings  
 0%
Total:457
This week:245
All time:5,956
This week:1Up
User Ratings User Comments (1)
 All timeMonth
Utility:93%StarStarStarStarStar93%Equal
Consistency:81%StarStarStarStarStar81%Equal
Documentation:62%StarStarStarStar62%Equal
Examples:--
Tests:--
Videos:--
Overall:61%StarStarStarStar61%Equal
Rank:12261Up
 
Very useful, thanks.
5 days ago (Octavio Leon)
70%StarStarStarStar