2010-12-29 10 views

答えて

2

は、まあ、私はsfGuardSecurityUserを読んでいると、それはsfBasicSecurityUserクラスを拡張し、魔女だからなど、ユーザー認証、プロファイル、資格情報、 を扱う、私は、ユーザーのセッションがisTimedOutと呼ばれる、時限プットであるか否かを判断するsfBasicSecurityUser内の関数を見つけました、およびsetTimedOutも使用します。

少なくとも、サーバー側でユーザーのセッションがタイムアウトしたときに何かしたい場合は、これが発生したときにスローされるイベントを待機する必要があります。この方法をチェックしてください:

これはsymfony_core_root_dir/libに/ユーザー/ 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'] = 1800; 
    } 

    // 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']); 
    } 

    // 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(); 
    } 

を見つけることができ、あなたはおよそHTML 5 and Javascript Workersを考え始めるかもしれません。このアイデアは、ページが読み込まれたときに作業者を設定し、session_time_outまでカウントしてからログインページなどにリダイレクトするように指示することができます。

関連する問題