1

I'm facing auto logout issue with OrangeHRM built with Symfony 1.2.4

What I have Tried?

  1. I have tried to allocate max time to SESSIONS via php.ini and .htaccess

  2. Tried after commenting following code of file /symfony/lib/vendor/symfony/lib/user/sfBasicSecurityUser.class.php

    public function initialize(sfEventDispatcher $dispatcher, sfStorage $storage, $options = array())
    {
    // initialize parent
    parent::initialize($dispatcher, $storage, $options);
    
    if (!array_key_exists('timeout', $this->options))
    {
      $this->options['timeout'] = 86400;
      //$this->options['timeout'] = 1800;
    }
    
    
    $this->options['timeout'] = 86400;
    //$this->options['timeout'] = 2 * 24 * 60 * 60;
    
    // force the max lifetime for session garbage collector to be greater than timeout
    /*if (ini_get('session.gc_maxlifetime') < $this->options['timeout'])
    {
      ini_set('session.gc_maxlifetime', $this->options['timeout']);
    }*/
    ini_set('session.gc_maxlifetime', $this->options['timeout']);
    
    // read data from storage
    $this->authenticated = $storage->read(self::AUTH_NAMESPACE);
    $this->credentials   = $storage->read(self::CREDENTIAL_NAMESPACE);
    $this->lastRequest   = $storage->read(self::LAST_REQUEST_NAMESPACE);
    
    if (null === $this->authenticated)
    {
      $this->authenticated = false;
      $this->credentials   = array();
    }
    else
    {
      // Automatic logout logged in user if no request within timeout parameter seconds
      $timeout = $this->options['timeout'];
      if (false !== $timeout && null !== $this->lastRequest && time() - $this->lastRequest >= $timeout)
      {
        if ($this->options['logging'])
        {
          $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Automatic user logout due to timeout')));
        }
    
        $this->setTimedOut();
        $this->setAuthenticated(false);
      }
    }
    
    $this->lastRequest = time();
    

    }

  3. Tried to set $_SESSION['symfony/user/sfUser/lastRequest'] manually.

  4. Tried to remain active via sending get request via AJAX.

  5. Tried to increase session time from YML setting file located in .../symfony/apps/orangehrm/config/factories.yml

    all:
      routing:
        class: sfPatternRouting
        param:
          generate_shortest_url:            true
          extra_parameters_as_query_string: true
      storage:
        class: sfSessionStorage
        param:
          session_name: PHPSESSID
          session_cache_limiter: nocache
      user:
         class: myUser
         param:
           timeout:         86000
           logging:         %SF_LOGGING_ENABLED%
           use_flash:       true
           default_culture: %SF_DEFAULT_CULTURE%
    

End Result

All of above techniques failed.

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50

2 Answers2

0

First, you should not touch files in the vendor directory !

The proper way to modify session lifetime in a symfony application is through the config.yml file. See this question for reference.

Community
  • 1
  • 1
Fred
  • 1,607
  • 20
  • 33
0

Even though this is a bit late, this will help you to extend the session timeout value. This setting is located in .../symfony/apps/orangehrm/config/factories.yml file.

There you will see the below setting,

all:
  routing:
    class: ohrmPatternRouting
    param:
      generate_shortest_url:            true
      extra_parameters_as_query_string: true
  storage:
    class: sfSessionStorage
    param:
      session_name: PHPSESSID
      session_cookie_secure: true
      session_cache_limiter: nocache
  user:
     class: myUser
     param:
       timeout:         1800 #change this value to change the session timeout interval
       logging:         %SF_LOGGING_ENABLED%
       use_flash:       true
       default_culture: %SF_DEFAULT_CULTURE%

The relevant value you should change is timeout parameter. Default value is 1800 seconds (30mins). If you are in the development environment, execute symfony clear cache command (in a terminal go inside the symfony folder and execute ./symfony cc) to get it working. Hope this helps!

Aruna Tebel
  • 1,436
  • 1
  • 12
  • 24