2010-12-29 2 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까지 카운트 한 다음 로그인 페이지 또는 다른 것으로 리디렉션하는 것으로 나타낼 수 있습니다.

관련 문제