echo $usercount; - displays users.
The following code must go at the very top of your page before any HTML is sent to the browser. To call the function and assign the value to a variable, you simple use this line:
$usercount = getUsersOnline();
<?php
session_start();
function getUsersOnline() {
$count = 0;
$handle = opendir(session_save_path());
if ($handle == false) return -1;
while (($file = readdir($handle)) != false) {
if (ereg("^sess", $file)) $count++;
}
closedir($handle);
return $count;
}
?>