XF 2.0 Increase Online status timeout

Hi guys, first post so go gentle, I've ported over from VB and am just having a little trouble increasing this option above the limited 60 minutes.

I found online how you do it on older version but not on ZF2?

Any help appreciated.

Matt
 

imno007

Well-known member
For whatever reason, you still can't do this with XF's default settings. You'll have to edit src/XF/Repository/SessionActivity.php, look for this line and change the value there:

$cutOff = \XF::$time - 3600;

You might also have to put the forum in dev mode and edit the value in your admin - I can't remember offhand if this is really necessary, but just in case. (Or maybe you could just do that and not actually have to edit the sessions file.) You'll get an error every time XF does a file health check, but you can ignore it.
 

imno007

Well-known member
Sorry, I think I left something off there. You'd have to also edit this line in sessionactivity.php:

$onlineCutOff = \XF::$time - $this->options()->onlineStatusTimeout * 60;

But like I said, first just try to put the forum in dev mode and see if editing the value in the admin suffices. All I know for sure is that I got it to work. It's been several months, though, so I'm a little fuzzy on everything I edited - I just copy the file contents over after updating.
 
Last edited:
Ive put it into dev mode and set the:
$onlineCutOff = \XF::$time - $this->options()->onlineStatusTimeout * 240;

Then gone into the user setting and tried to amend it there too but it wont take, its refused to go over 60.

Anything else I can do or is it set to 240 mins now as specified in the sessionactivity.php?

The logged in members has not gone up significantly so I assume not and error reporting is highlighting a mis match in the code which is down to the maximum allowed of 60 conflicting with the 240 I've put in the sessionactivity.php
 

imno007

Well-known member
These are the relevant bits I've changed:

$onlineCutOff = \XF::$time - $this->options()->onlineStatusTimeout * 1440; (minutes to hours= 24 hours)
}

return $this->db()->fetchRow("
SELECT
SUM(IF(user_id >= 0 AND robot_key = '', 1, 0)) AS total,
SUM(IF(user_id > 0, 1, 0)) AS members,
SUM(IF(user_id >= 0 AND robot_key = '', 1, 0)) AS members (this is "AS guests" by default, so up to you if you want to fudge those numbers. I don't have guests, so....)
FROM xf_session_activity
WHERE view_date >= ?
", $onlineCutOff);
}


And here:

public function pruneExpiredActivityRecords($cutOff = null)
{
if ($cutOff === null)
{
$cutOff = \XF::$time - 86400; (seconds to hours= 24 hours)



Then you have to put your forum in dev mode and edit this in Admin/Options/User options:

198038

I don't know if it's really necessary to change this last value to affect the status timeout, but if you don't you won't be able to save after changing any of the options on that page.


EDIT: Oh yeah, one more thing. You'll probably have to change the highlighted line here too in order to be able to save (by clicking the little "Edit" link you see in the above image):

198040
 
Last edited:

trapped_soul

Well-known member
These are the relevant bits I've changed:

$onlineCutOff = \XF::$time - $this->options()->onlineStatusTimeout * 1440; (minutes to hours= 24 hours)
}

return $this->db()->fetchRow("
SELECT
SUM(IF(user_id >= 0 AND robot_key = '', 1, 0)) AS total,
SUM(IF(user_id > 0, 1, 0)) AS members,
SUM(IF(user_id >= 0 AND robot_key = '', 1, 0)) AS members (this is "AS guests" by default, so up to you if you want to fudge those numbers)
FROM xf_session_activity
WHERE view_date >= ?
", $onlineCutOff);
}


And here:

public function pruneExpiredActivityRecords($cutOff = null)
{
if ($cutOff === null)
{
$cutOff = \XF::$time - 86400; (seconds to hours= 24 hours)



Then you have to put your forum in dev mode and edit this in Admin/Options/User options:

View attachment 198038

I don't know if it's really necessary to change this last value to affect the status timeout, but if you don't you won't be able to save after changing any of the options on that page.


EDIT: Oh yeah, one more thing. You'll probably have to change the highlighted line here too in order to be able to save (by clicking the little "Edit" link you see in the above image):

View attachment 198040
You are a legend!
Oh my word. I literally couldn't find how to edit the ACP options as before, when we had the spanner icon..
Enable DEV mode is what was catching me out. I enabled Debug not DEV. :rolleyes:🤦‍♂️
Thank you so much! It's that which I was missing.. what a muppet.
Anyway, seems to be all good. As soon as I enabled dev mode, I finally had the options to edit the user options.
Much appreciated!
 

Masetrix

Well-known member
[...]
You have to put your forum in dev mode and edit this in Admin/Options/User options:

View attachment 198038

I don't know if it's really necessary to change this last value to affect the status timeout, but if you don't you won't be able to save after changing any of the options on that page.


EDIT: Oh yeah, one more thing. You'll probably have to change the highlighted line here too in order to be able to save (by clicking the little "Edit" link you see in the above image):

View attachment 198040
In XF 2.1.1 it is sufficient to execute and save your steps copied from me above. Then set /admin.php?options/groups/users/ to the right Timevalue.
 

Masetrix

Well-known member
In XF 2.1.1 it is sufficient to execute and save your steps copied from me above. Then set /admin.php?options/groups/users/ to the right Timevalue.
I am wrong. We have to do all steps...
But for now it works for me.

Thanks for sharing what the Devs will not get in the core... 😁
 

imno007

Well-known member
Last edited:
Top