How to tell if a member is online or offline?

Hai, i'm new to cookies/sessions, so i'm not sure how to do this. So, theres a row in the user account table called 'online'. When their online, the value is 1. When their offline, the value is 0. I'm not sure how to do this, like to store a cookie then remove it when they leave? Halp please :D

If everyone is required to sign-in, then you can update the "online" indicator when they sign in. When they sign out or after they have been inactive for a certain amount of time, you can reset it to "offline". If you can also have active users who aren't signed in (just browsing), then you can also get the total count of active sessions - see the link below:

One thing to keep in mind: Some users may not log out, or may just go away from the comp with the window still up, leaving their session active far past when they should really be considered online. Figure out how you want to define an "online" user.