How to check who is currently logged in?
Posted: Thu Apr 10, 2008 10:06 pm
How do I go about checking to see who is logged onto my website?
if(isset($_SESSION['userID'])){
display content for logged in user
}
else{
display content for non-logged in user
}
this will tell me what to echo depending if the user is logged in or not.
But how do I check every user account in the db and determine who is currently logged in?
If a user logs into the site, I can set a loggedIn field in the user's table to 'true'.
Then when the user clicks the log out button, I can easily set that field to false...but if the user closes the browser or navigates to another site, I am without a clue on how to update the db...
Any ideas???
if(isset($_SESSION['userID'])){
display content for logged in user
}
else{
display content for non-logged in user
}
this will tell me what to echo depending if the user is logged in or not.
But how do I check every user account in the db and determine who is currently logged in?
If a user logs into the site, I can set a loggedIn field in the user's table to 'true'.
Then when the user clicks the log out button, I can easily set that field to false...but if the user closes the browser or navigates to another site, I am without a clue on how to update the db...
Any ideas???