2016-05-11 73 views
1

我面臨着OrangeHRM自動退出問題與Symfony 1.2.4OrangeHRM自動註銷問題

建什麼我都試過?

  1. 我試圖通過php.ini分配最大的時間會和.htaccess

  2. 註釋文件的下面的代碼/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. 試圖設置後嘗試$_SESSION['symfony/user/sfUser/lastRequest']手動。

  4. 試圖通過AJAX通過發送獲取請求保持活動狀態。

  5. 試圖從位於.../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% 
    

最終結果

所有的上述技術失敗YML設置文件增加會話時間。

回答

0

首先,您不應該觸摸供應商目錄中的文件!

在symfony應用程序中修改會話生存期的正確方法是通過config.yml文件。 See this question for reference

+0

你好,謝謝你的回覆。我已經嘗試過您提供的解決方案,但仍面臨問題。 – Hassaan

+0

我的symfony版本是'1.2.4' – Hassaan

0

即使這有點晚,這將有助於延長會話超時值。該設置位於.../symfony/apps/orangehrm/config/factories.yml文件中。

在那裏你會看到下面的設置,

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% 

相關的價值,你應該改變的是timeout參數。默認值是1800秒(30分鐘)。如果您處於開發環境中,請執行symfony clear cache命令(在終端中進入symfony文件夾並執行./symfony cc)以使其工作。希望這可以幫助!

+0

感謝您的回覆。我已經嘗試過這個,但失敗了。請再次看到我的更新答案。 – Hassaan