Kohana_Auth::logout PHP 메소드

logout() 공개 메소드

Log out a user by removing the related session variables.
public logout ( $destroy = FALSE, $logout_all = FALSE ) : boolean
리턴 boolean
    public function logout($destroy = FALSE, $logout_all = FALSE)
    {
        if ($destroy === TRUE) {
            // Destroy the session completely
            $this->_session->destroy();
        } else {
            // Remove the user from the session
            $this->_session->delete($this->_config['session_key']);
            // Regenerate session_id
            $this->_session->regenerate();
        }
        // Double check
        return !$this->logged_in();
    }

Usage Example

예제 #1
0
 /**
  * Log a user out and remove any autologin cookies.
  *
  * @param   boolean  completely destroy the session
  * @param	boolean  remove all token for user
  * @return  boolean
  */
 public function logout($destroy = FALSE, $logout_all = FALSE)
 {
     // Set by force_login()
     $this->_session->delete('auth_forced');
     if ($token = Cookie::get('authautologin')) {
         // Delete the autologin cookie to prevent re-login
         Cookie::delete('authautologin');
         if ($logout_all) {
             // Load the user from the token
             $user = new Model_User();
             $user->where('token', '=', $token)->limit(1)->find();
             // generates new autologin token from the database
             if ($user->loaded()) {
                 $user->create_token();
             }
         }
     }
     return parent::logout($destroy);
 }