How to count users online with PHP

[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
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;

    $handle = opendir(session_save_path());
    if ($handle == false) return -1;

    while (($file = readdir($handle)) != false) {
    if (ereg("^sess", $file)) $count++;
    }
    closedir($handle);

    return $count;
    }

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


Allen
http://www.datingfunda.com/