Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/
Share on other sites

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 . . .

Link to comment
https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/#findComment-343648
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/#findComment-343662
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/#findComment-343665
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/68348-not-sure-what-to-do/#findComment-343701
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.