wintallo Posted March 10, 2007 Share Posted March 10, 2007 Hey, Right now, I'm working on a user authentication system. My problem is with an "online status" element. So far, I have that when the user logs in, a field in my members MySQL table, called loggedinstatus is set to 1. This means that that certain user is currently logged in. The problem is, is that the only way that loggedinstatus is set to 0 (the user is not logged in) is when the user clicks the logout link. If the user just goes to another website or closes his or her browser, the loggedinstatus is left at 1. How would I get around this problem? Quote Link to comment https://forums.phpfreaks.com/topic/42069-php-mysql-online-status-for-user-authentication-system/ Share on other sites More sharing options...
wintallo Posted March 10, 2007 Author Share Posted March 10, 2007 Oh, and I don't have cookies implemented as a remember me function. Should I use cookies? Quote Link to comment https://forums.phpfreaks.com/topic/42069-php-mysql-online-status-for-user-authentication-system/#findComment-204039 Share on other sites More sharing options...
redarrow Posted March 10, 2007 Share Posted March 10, 2007 use cookies then to exspire by time. Quote Link to comment https://forums.phpfreaks.com/topic/42069-php-mysql-online-status-for-user-authentication-system/#findComment-204041 Share on other sites More sharing options...
wintallo Posted March 10, 2007 Author Share Posted March 10, 2007 I have almost no experience with PHP cookies. Can I get a nudge in the right direction? Thanks for the reply! Quote Link to comment https://forums.phpfreaks.com/topic/42069-php-mysql-online-status-for-user-authentication-system/#findComment-204042 Share on other sites More sharing options...
redarrow Posted March 10, 2007 Share Posted March 10, 2007 http://uk3.php.net/setcookie BIG NUDGE Quote Link to comment https://forums.phpfreaks.com/topic/42069-php-mysql-online-status-for-user-authentication-system/#findComment-204043 Share on other sites More sharing options...
wintallo Posted March 10, 2007 Author Share Posted March 10, 2007 So I could set a cookie every time a logged in user goes to a page setcookie("loggedin", 1, time()+60*10); But how would this help? Yes, after 10 minutes the cookie would die, but how could I interface this with a database? I want to use this so that on a user list, people could see which users are online and which are not. I might just be missing something really obvious Thanks for your time! Quote Link to comment https://forums.phpfreaks.com/topic/42069-php-mysql-online-status-for-user-authentication-system/#findComment-204050 Share on other sites More sharing options...
redarrow Posted March 10, 2007 Share Posted March 10, 2007 if you enter a website a database get's the users id name and date now what can you do with that in a new table. maybe setup a login and logout code try. and yes will help but you need to help also by trying to understand ok mate so with this i would come on? 1. setup a new what ? ohh table within the table i want what columns? Quote Link to comment https://forums.phpfreaks.com/topic/42069-php-mysql-online-status-for-user-authentication-system/#findComment-204056 Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 The best way is to have a field in your db that states "Last action time". Use that in your script that if a user's times is greater than 5 minutes it updates the "loggedin" field to be set to 0. There is no other way to obtain this as it is impossible to tell if a user closes their browser/goes to another site. --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42069-php-mysql-online-status-for-user-authentication-system/#findComment-204085 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.