【发布时间】:2011-06-20 06:46:05
【问题描述】:
我是 Zend 的新手
我搜索了它并得到了以下链接, how to keep track of currently logged user in zend framework.
但我的要求不同。
我的情况是,我有一个名为 AuthenticationController 的单独控制器来使用 Zend_Auth 在会话中存储记录的用户详细信息并做其他事情,现在我必须获取记录的用户信息,当每次登录用户访问每个页面时网站。
所以我必须在每次触发的公共文件中执行一些逻辑才能在 zend 中获取用户信息。
如何在 zend 中做到这一点?
以下是示例代码..
if ($form->isValid($request->getPost())) {
if ($this->_process($form->getValues())) {
$authentication = Zend_Auth::getInstance();
if ($authentication ->getIdentity()->myfirstlogin == 0) {
$this->_helper->redirector('index', 'test1');
} else {
$this->_helper->redirector('index', 'test2');
}
} else {
$myUserStatus = new Zend_Session_Namespace('myuserStatus');
if ($myUserStatus ->status == 2) {
$this->_helper->FlashMessenger('Incorrect Username / Password');
} else if ($myUserStatus ->delete == 1) {
$this->_helper->FlashMessenger('Your **** approval.');
} else {
$this->_helper->FlashMessenger('Please ****** administrator');
}
unset($myUserStatus);
$this->_helper->redirector('index', 'auth');
}
}
.......
【问题讨论】:
-
请分享一些代码...如果您没有以标准方式进行身份验证...如果没有任何代码,我们不可能知道您的情况。
标签: php zend-framework