1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'XenForo Questions and Support' started by Malchus, Sep 18, 2011.

  1. Malchus

    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.

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

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

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

    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...
    imno007, crazy, Eagle and 1 other person like this.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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:

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

    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):

    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::set('options', $options);

    Attached Files:

  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  5. ScottLott

    ScottLott Member

    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.
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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:

    	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.
    Adam Howard likes this.
  7. ScottLott

    ScottLott Member

    Alright, I've made the change. I'll set up an idle browser window and check back on it in 2 hours.
  8. Brivium

    Brivium Well-Known Member

    I found that session timeout be cleared by Hourly Cron job -> This is the reason for maximum time = 60 minutes.
    Wartazan likes this.
  9. imno007

    imno007 Well-Known Member

    Is there any way to prevent this?
  10. James

    James Well-Known Member

    Delete/disable the cron job.
  11. imno007

    imno007 Well-Known Member

    Sorry, let me rephrase that: how exactly would I go about disabling the cron job? What do I need to edit where? Thanks
  12. imno007

    imno007 Well-Known Member

  13. topcat

    topcat Well-Known Member

    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?
  14. Jens1986

    Jens1986 Active Member

    Does this work at 1.2 as well?
  15. imno007

    imno007 Well-Known Member

    Doesn't work. You have to disable the cron job, as noted above.
    Jake Bunce likes this.
  16. blake247

    blake247 Member

  17. JamesBrown

    JamesBrown Well-Known Member

    What is the name of the cron job that we need to disable?
  18. imno007

    imno007 Well-Known Member

    In your admin, under Tools/Cron Entries: Hourly Clean Up
  19. JamesBrown

    JamesBrown Well-Known Member

    Can anyone tell me what mess might be left if this job is disabled?
  20. imno007

    imno007 Well-Known Member

    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.

Share This Page