title: PHP: Server check if user is logged in or out
body: <p>I'm wanting to be able to tell if a user is logged in or not from the server end.  I currently have it set up where each user record in my database has an attribute 'loggedin' (boolean). If my user goes through the login process then he/she's 'loggedin' is set to '1'(true). If the user goes through the logout page I set it to '0'(false).  My problem is what if they don't go through the logout page but instead their cookie times out?</p>
  
  <p>In hopes of helping anyone better understand what I'm trying to accomplish. I'm just trying to make a feature that will show on user's pages how long it has been since they were last logged in. I have it currently calculating but it shows either "user is online" or "online 4 minutes ago" depending on the 'loggedin' value in the database described earlier. So, if I visit a friends page then it will tell me how long ago it's been since they've been on.</p>
  
  <p>** Just thought maybe store in the database another attribute that stores the timeout time of the cookie after login, so I could check for the 'loggedin' value and their timeout value to determine which information to display. This doesn't seem to be a very good way of doing it but i don't know.</p>
  
  <p>If you have a better way of doing this than the method I've described above please clue me in :)</p>
  
  <p>Thanks for any information!</p>