我使用Zend_Auth作为我的一个项目,但到目前为止还没有弄清楚如何设置会话的生命周期,或者如何扩展它(假设它应该运行5分钟,并应该重置为用户做出动作时),这是我的初始化代码:
$authAdapter = new Zend_Auth_Adapter_DbTable($this->_model->pdo); $authAdapter->setTableName('normal_folks') ->setIdentityColumn('username') ->setCredentialColumn('password'); $post = $this->_request->getPost(); $authAdapter->setIdentity($post['username']) ->setCredential($post['password']); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if($result->isValid()) { $userInfo = $authAdapter->getResultRowObject(null,'password'); $authStorage = $auth->getStorage(); $authStorage->write($userInfo); if(strlen($post['refferer']) > 1){ header("Location: ".$post['refferer']); }elseif(strlen($this->_request->getParam('ref_action')) > 1){ Zend_Controller_Action::_forward($this->_request->getParam('ref_action'),"admin",null,null); }else{ Zend_Controller_Action::_forward("index",null); } }
if(Zend_Auth::getInstance()->hasIdentity()){ echo "Woho!"; }else{ die("invalid-identity"); }
它可能就在我面前,但我无法理解,帮助?请?好吗? :d
身份验证状态存储在已注册的Auth Storage中.默认情况下,这是Zend_Session.你可以
set an expiration time to the
原文链接:https://www.f2er.com/php/134733.htmlZend_Auth
namespace,例如
$namespace = new Zend_Session_Namespace('Zend_Auth'); $namespace->setExpirationSeconds(300);
你也可以globally configure Zend_Session
通过
Zend_Session::setOptions(array( 'cookie_lifetime' => 300,'gc_maxlifetime' => 300));