PHP Classes

File: readme.md

Recommend this page to a friend!
  Classes of John S.   PHP Session Count Online Users   readme.md   Download  
File: readme.md
Role: Documentation
Content type: text/markdown
Description: Read Me Documentation
Class: PHP Session Count Online Users
Get the number of users that are online in a site
Author: By
Last change: fix markdown
Date: 5 years ago
Size: 754 bytes
 

Contents

Class file image Download

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