2016-05-11 21 views
1

は、私が試してみました何Symfony 1.2.4OrangeHRM自動ログアウト問題

で構築されましたか?私はファイルの次のコード/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(); 

}

  • をコメントした後試みphp.ini.htaccess

  • 介してセッションへの最大時間を割り当てることを試みた

    1. を設定しよう$_SESSION['symfony/user/sfUser/lastRequest']を手動で入力してください。

    2. AJAXでリクエストを送信しても有効であるように試みました。

    3. は、上記の技術のすべてが失敗した.../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