# How to count users online with PHP

**URL:** <https://forum.kirupa.com/t/how-to-count-users-online-with-php/238717>\
**Category:** Uncategorized\
**Created:** [September 14, 2007, 7:52am UTC](https://forum.kirupa.com/t/how-to-count-users-online-with-php/238717 "2007-09-14T07:52:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pattersonz](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@pattersonz](https://forum.kirupa.com/u/pattersonz)\
**Post date:** [September 14, 2007, 7:52am UTC](https://forum.kirupa.com/t/how-to-count-users-online-with-php/238717/1 "2007-09-14T07:52:59Z")

</div>

[FONT=&quot] [/FONT]hi

the simpler way to calculate the number of users online at the same time: simply count the number of session files developed by my friend at [web design company](http://www.webdesigningcompany.net)  
works really  
[CENTER] **Code:**  
session\_start();

/\*\*

- Calculate the number of users online by

- counting the number of session files. Returns the

- number of users on success, or -1 on failure.  
\*/  
function getUsersOnline() {  
$count = 0;

echo "users online = " . getUsersOnline();  
[/CENTER]

* * *

Allen  
[http://www.datingfunda.com/](http://www.datingfunda.com/)
