: -
$auth = Zend_Auth::getInstance ();
$authAdapter = new Zend_Auth_Adapter_DbTable ();
$authAdapter->setIdentity ('Sameer');
$result = $auth->authenticate ( $authAdapter );
$data->role = '20';
$auth->getStorage()->write($data);
$this->_redirect('/default/dashboard');
重定向后:
$auth = Zend_Auth::getInstance ();
print_r($auth);
显示空白无显示 请帮忙......
如果我之后使用退出 重定向后:
$auth = Zend_Auth::getInstance ();
print_r($auth);
exit;
然后没有任何显示其他方式重定向回登录页面...
答案 0 :(得分:0)
试试这个:
<强>登录强>
$auth = Zend_Auth::getInstance();
if(!$auth->hasIdentity()) {
$authAdapter = new Zend_Auth_Adapter_DbTable ();
$authAdapter->setIdentity ('Sameer');
$result = $auth->authenticate ( $authAdapter );
if($result->isValid()) {
//get the found identity
$identity = $result->getIdentity();
//$data->role = '20';
$auth->getStorage()->write($identity);
$this->_redirect('/default/dashboard');
}
else {
$error = $result->getMessage();
die($error);
}
}
else {
//already logged in
$this->_redirect('/default/dashboard');
}
要获得更好的调试数据,请将此行添加到 index.php
的开头ini_set('display_errors','On');
error_reporting(E_ALL);