users logged in or not in php?

  • Thread starter Thread starter jack
  • Start date Start date
J

jack

Guest
Hey, I couldn't figure a way to work in seeing if users were logged in or not on my site, so I just used a simple UPDATE to the sql under each username when they went through the log in process, as shown below:

$update = mysql_query("UPDATE `members` SET `online` = '[ONLINE]' WHERE `username` = '$logged[username]'");

so it updates the online field with the word "[ONLINE]" and under each username, i just call $online, to show the text.

well to show that they've logged out, i put in the logout.php page, just the opposite,

$update = mysql_query("UPDATE `members` SET `online` = '' WHERE `username` = '$logged[username]'");

which just changes the text "[ONLINE]" to ""

though what i didn't think of is that most users to log out, they just close the page.. so without going through the logout process, i'm left with about every user shown as online.. forever.

So i tried putting on the index.php

basically, if user is logged, then change to [ONLINE] else, change to ""

though when they exit the site, that doesn't run the ELSE command really.. so is there a way I can show users as offline or pretty much just take away the [ONLINE] text if they simply close the website?
 
Back
Top