验证Zend_Auth会话的问题

时间:2014-07-15 03:50:22

标签: php zend-framework

晚上好,我有这段代码,但我需要知道这是否真的记录了但是没有成功,我错了吗?这个scritp没有告诉我任何错误:(

                  $userDetails = array('foo' => 'bar');
$storage = new Zend_Auth_Storage_Session();
// set sorage for Zend_Auth
Zend_Auth::getInstance()->setStorage($storage);
// write data to the storage
Zend_Auth::getInstance()->getStorage()->write($userDetails);
// read data from storage
$c = Zend_Auth::getInstance()->getStorage()->read();
    $result = $c->authenticate($userDetails);
                             echo $this->view->form = var_dump($result);

 if (!$result->isValid()){
     var_dump('FAILURE');
}else{                          
     $this->_helper->redirector('index','index');

}

1 个答案:

答案 0 :(得分:0)

您可以在session中查看Zend

if (Zend_Auth::getInstance()->hasIdentity()) {
    // do user session action
} else {
    // redirect to login page
}

要获取用户信息,请尝试

$userInfo = Zend_Auth::getInstance()->getStorage()->read();