Script utilizing SRM to count the users 'online':
<?php
$srm = new SRM ('/var/srm.socket');
$srm->user_active($_COOKIE['PHP_SESSID']);
echo $srm->get_active_user_count();
?>
Daemon side:
<?php
$active_users = array();
function user_active($id) {
$GLOBALS['active_users'][$id] = time();
}
function cleanup_inactive_users() {
foreach($GLOBALS['active_users'] as $id => $time) {
if ($time < time() - 300) {
unset($GLOBALS['active_users'][$id]);
}
}
}
function get_active_user_count() {
cleanup_inactive_users();
return count($GLOBALS['active_users']);
}
?>