1

で構築された OrangeHRM で自動ログアウトの問題に直面していますSymfony 1.2.4

私が試したことは何ですか?

  1. php.iniおよび経由で SESSIONS に最大時間を割り当てようとしました.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. 経由で get リクエストを送信して、アクティブのままにしようとしましAJAXた。

  5. YMLにある設定ファイルからセッション時間を増加させようとしました.../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%
    

最終結果

上記の手法はすべて失敗しました。

4

2 に答える 2

0

まず、 vendor ディレクトリ内のファイルには触れないでください!

symfony アプリケーションでセッションの有効期間を変更する適切な方法は、config.yml ファイルを使用することです。この質問を参照してください

于 2016-05-11T16:44:22.227 に答える
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)、機能させます。お役に立てれば!

于 2016-05-22T14:27:28.740 に答える