Aureole Posted September 7, 2007 Share Posted September 7, 2007 Ok basically when someone logs in I set a session variable to 1 $_SESSION['logged_in'] and I also update the Databse, member table and set the field mem_online to 1. Now the problem with this is if the session times out due to inactivity, the mem_online field is still set to 1 so although the Member isn't online, on their profile and on the online memberlist they are shown as online. Basically I need a way to update mem_online to 0 once the user has been inactive for a certain amount of time. I'm not really sure how to approach this. Any input is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/ Share on other sites More sharing options...
Styles2304 Posted September 7, 2007 Share Posted September 7, 2007 where ever you have the code to determine when the user logs out, just do a mysql query and update the mem_online. $query = "UPDATE <i>table name</i> SET mem_online = 0;"; mysql_query ($query,<i>database info</i>) or die(mysql_error()); Hope that helps . . . Quote Link to comment https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/#findComment-343648 Share on other sites More sharing options...
Aureole Posted September 7, 2007 Author Share Posted September 7, 2007 I already have it like that, you don't understand...if the member logs out then that's fine and it gets set to 0. But if they DON'T log out, instead their session times out from inactivity. So they're not actually logged in but in the database they are...because the session timing out doesn't affect the database "mem_online" field... Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/#findComment-343662 Share on other sites More sharing options...
Styles2304 Posted September 7, 2007 Share Posted September 7, 2007 Yeah . . . what I'm telling you is in the section where you determine how they time out (unless you didn't write that code yourself) you need to add what I posted. Sorry if I don't understand, but I'm answering based on what you've given me. Maybe it would help if you posted some code? Quote Link to comment https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/#findComment-343665 Share on other sites More sharing options...
Aureole Posted September 7, 2007 Author Share Posted September 7, 2007 I haven't coded it myself for when the session times out, I don't know how to do that... ??? Well which code should I post? Sign-in and sign-out? Or... ??? Thanks for your help so far anyway. Quote Link to comment https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/#findComment-343668 Share on other sites More sharing options...
bapi Posted September 7, 2007 Share Posted September 7, 2007 Hi, U can add "sessionid" field into the table where u keep the online information. next create a script, which compare session id with table ever time when some one login. Hope this will help ! Quote Link to comment https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/#findComment-343699 Share on other sites More sharing options...
Styles2304 Posted September 7, 2007 Share Posted September 7, 2007 Ok . . . when it times them out . . . does it send them to another page? If so . . . it should close the session and all the $_SESSION[] variables. If that's the case, on the page it sends you to, I would have it check for a certain variable, maybe $_SESSION['logged_in']; so maybe something like: if (!$_SESSION['logged_in']) { $query = "UPDATE table name SET mem_online = 0;"; mysql_query ($query,database info) or die(mysql_error()); } else {} This is just a guess though . . . if when the user is timed out, the $_SESSION variables aren't reset, I don't know how to help you. Quote Link to comment https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/#findComment-343701 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.