Does anyone know of a thorough guide to messing about with sessions? There are certain things I'd like to do which would require using sessions to determine things. For instance, if I'm logged into the site I would like others to know that I'm logged in as well. I'm guessing session data would be used to determine whether or not the user is actually logged in, but how can I determine when the session ends (let's say, closes the browser, not necessarily clicks the log out option) to remove their online status?

There are more things I'd like to do, but the only thing I seem to know how to do with sessions is set an expire date and grab the logged in user. I don't know how to do something like visit someone's profile and find out if they're logged in by finding if they have an active session using their user_id. Any ideas? Thanks!