晚上好,我有这段代码,但我需要知道这是否真的记录了但是没有成功,我错了吗?这个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');
}
答案 0 :(得分:0)
您可以在session
中查看Zend
,
if (Zend_Auth::getInstance()->hasIdentity()) {
// do user session action
} else {
// redirect to login page
}
要获取用户信息,请尝试
$userInfo = Zend_Auth::getInstance()->getStorage()->read();