0

再会,

我正在使用 Zend 测试用户身份验证,但现在我已经登录,然后我再次注销它让我保持登录状态,所以我无法测试以确保它正常工作。

我用:

$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity())

它总是让我拥有一个身份并允许我查看资源。

是否可以在注销时清除缓存、会话或 cookie,或者在不取消注释行等的情况下进行彻底测试的方法。

谢谢

登出:

$auth = Zend_Auth::getInstance();
        if ($auth->hasIdentity())
            $auth->clearIdentity();

        $this->_redirect('/');
4

1 回答 1

0

我认为, $auth->clearIdentity(); 就足够了但是为了测试让你的注销操作像这样,

 public function logoutAction() {
    Zend_Auth::getInstance()->clearIdentity();
    $storage = new Zend_Auth_Storage_Session();
    $storage->clear();
    $this->_helper->redirector('Action', 'Controller'); // back to main page
}
于 2013-10-15T08:47:27.713 回答