Not been a PHP guru but a Unix scripter couldn't you try and do the follwing.
I know its not very pretty but why not do this to log what you're wanting to know. File could get quite big though
Create the sql file whos_online.sql
Code:
echo "select userid, host, lastactivity, location from session \G" | /opt/mysql/bin/mysql database_name 1>>/tmp/whos_online.log 2>&1
Or you could just add a where clause in for certain users if you wanted.
And then cron up to run every min.
Hope this helps.