You can do this in each script. For the login script you simply UPDATE that mysql field for the user to be a 1. For the logout script you query the database to UPDATE the field to be 0.
But using that method, if a user does not log out by clicking log out, then they will still appear logged in.
This is why PHP "user online" scripts work by checking a time difference of now() and the last time they were active on a page or surfing the site. If the time difference is more than 5 minutes since their last activity... you remove them from the "userOnline" database table made for logging and unlogging active users.
I used to have that system here where I had a table that would add each member that is active on the site. Then my PHP script would check to see if their last activity time is past 5 minutes ago... if it was... they get removed and appear "offline".
Adam Forum & Site XP Level: United States of America
NC
Lake Toxaway Scorpio
Posts: 4366
Joined: 04/20/08
Website: URL