How to set the default time for users to stay logged in

Malchus

Member
I want my forums to have no logout timeout. But the maximum is 60 minutes. Is there a way to set it to infinity?

Thank you in advance.

Cheers.
 
If you enable debug mode by adding this line to your library/config.php file:

Code:
$config['debug'] = 1;

Then you can edit the definition of that option to change the maximum:

Screen shot 2011-09-18 at 12.56.20 AM.webp

The problem is that this will be overwritten when you upgrade. I am trying to come up with a listener that will allow you to override this setting...
 
Ok this appears to work...

Download the attached zip file, unzip, and upload the contents to the library directory on your server. You will have this file structure:

library
> OverrideSessionTimeout
> > Listener.php


Then enable debug mode as before. Create a new listener:

Admin CP -> Development -> Code Event Listeners -> Create New Code Event Listener
> Listen to Event: init_dependencies
> Execute Callback: OverrideSessionTimeout_Listener :: override

Screen shot 2011-09-18 at 2.12.30 AM.webp

Save that and you should be good to go. You can edit Listener.php to set the timeout. I have it set to 1440 minutes (1 day):

Rich (BB code):
<?php

class OverrideSessionTimeout_Listener
{
	public static function override(XenForo_Dependencies_Abstract $dependencies, array $data)
	{
		$options = new XenForo_Options($data['options']);
		$options->__set('onlineStatusTimeout', 1440);
		XenForo_Application::setDefaultsFromOptions($options);
		XenForo_Application::set('options', $options);
	}
}
 

Attachments

Not to beat a dead horse here, but I have XenForo setup through a membership software package, aMember. aMember has a logout timeout of 2 hours, this was causing an issue for the unified login/logout system as the users would be logged out of XenForo but not logged out of aMember! As far as I can tell, this fixes the issue since I can extend XenForo's logout time to the same as aMembers. So there you go search engine spider.
 
I recently discovered that the session records themselves expire after 1 hour, so setting the online timeout any higher than that doesn't work (even if you force it with the above addon).

The expiry on session records is set in library/XenForo/Session.php. 3600 seconds is 1 hour:

Rich (BB code):
	public function __construct(array $config = array(), Zend_Cache_Core $cache = null, Zend_Db_Adapter_Abstract $db = null)
	{
		if (empty($config['admin']))
		{
			$defaultConfig = array(
				'table' => 'xf_session',
				'cacheName' => 'session',
				'cookie' => 'session',
				'lifetime' => 3600
			);
		}

This needs to be increased in addition to installing the above addon. I haven't tested this though.
 
What else does the houly clean up do, is it important,

can the cron file be edited to remove just this part of it so the the other jobs of the hourly clean up still run?
 
Ok this appears to work...

Download the attached zip file, unzip, and upload the contents to the library directory on your server. You will have this file structure:

library
> OverrideSessionTimeout
> > Listener.php


Then enable debug mode as before. Create a new listener:

Admin CP -> Development -> Code Event Listeners -> Create New Code Event Listener
> Listen to Event: init_dependencies
> Execute Callback: OverrideSessionTimeout_Listener :: override

View attachment 18894

Save that and you should be good to go. You can edit Listener.php to set the timeout. I have it set to 1440 minutes (1 day):

Rich (BB code):
<?php

class OverrideSessionTimeout_Listener
{
    public static function override(XenForo_Dependencies_Abstract $dependencies, array $data)
    {
        $options = new XenForo_Options($data['options']);
        $options->__set('onlineStatusTimeout', 1440);
        XenForo_Application::setDefaultsFromOptions($options);
        XenForo_Application::set('options', $options);
    }
}


Does this work at 1.2 as well?
 
Can anyone tell me what mess might be left if this job is disabled?
Thanks
I've had it disabled for a long time and it hasn't resulted in any "mess," but it does also affect Last Activity/last seen, see here.

I gather the last seen location is generally supposed to disappear after a couple hours, but I know I can see a person's last seen location going back a day or two, I guess because I have that cron disabled. Anyway, someone with more knowledge of Xenforo's inside workings will have to tell you more than that, if there's anything more to tell. I can say, though, that I don't notice any performance impact and no one is complaining about anything not working right on the forums, so I'm personally not much concerned with it. Until there's some other way to do this, I'll be keeping it disabled.
 
Top Bottom