I have my own login system - which authenticates against a MySQL database
and then uses sessions to keep track of logins.  It registers a session
variable for last access time, and logs access to pages in a separate table.
Then I can do things like this:

function currently_active_users(){
        //Returns a formatted string of currently logged in (and with valid
sessions) users
        $query = "SELECT DISTINCT user_id from log_access WHERE
(UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(lastaccess)) < (30*60)";//Users
accessing the site in last half an hour.
        $db = db_connect();
        $result = mysql_query($query, $db);
        while ($row = mysql_fetch_array($result)) {
                $users_online .= $row["user_id"];
                $users_online .= ", ";
        } //loop through and add returned users to string.
        $users_online = substr($users_online, 0, -2);//Ditch last comma and
space.
        return $users_online;
}

Dunno if this is any use to you?

Mick

-----Original Message-----
From: Research and Development [mailto:[EMAIL PROTECTED]]
Sent: 25 September 2002 23:26
To: PHP General List
Subject: Who is online script example


Hello. Has anyone noticed that some sites can display a list of users 
currently looking at their site? I would like to see the code to do 
such things.

Thanks in advance.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to