The best way is to just on login, send a session cookie to the user or a cookie that expires when the user leaves the website. Then when the user accesses a page with the cookie then a `online` column in the mysql user database will turn into the current timestamp value. Then a cron job checks if that timestamp subtract the current timestamp is greater than 150 seconds and if that is true then php will replace the timestamp with 0 making the user offline. Hope you could understand that.
i have great solution for ur question-- all u have to do is this
make a column in the database where u pick username and password to login-- name it status_flag with default value 0
now write a querry wen username and password matches
update status flag =1 where user name is "------"
and use session
and wen u will logout then update again the status to 0
i have its script u can contact me at <snip>
Seen this before, but a problem arises when a user leaves the site without logging out. You need to run a script with a timestamp of some description. A cron job to check the last page impression is one way - although cron jobs may be a little 'expensive'.