zend session和zend Auth in zend 2.2.4

时间:2013-11-17 09:27:52

标签: zend-framework

我刚刚在zend framework 2.2.4中登录了一个用户并将整个数据行存储在存储中。这是在成功登录后的切换案例中                        case Result :: SUCCESS:

                                             $storage=$auth->getStorage();
                                             $storage->write($authAdapter->getResultRowObject(null,'usr_password'));

                                             $time=1209600;
                                             if($data['Remember_Me'])
                                             {
                                                 $sessionManager=new \Zend\Session\SessionManager();
                                                 $sessionManager->rememberMe($time);

                                             }
                                            break;

如何从存储中读取数据并将其传递给视图。请提前帮助。谢谢

1 个答案:

答案 0 :(得分:0)

控制器中的

if (Zend_Auth::getInstance()->hasIdentity())
{
      $storage = Zend_Auth::getInstance()->getStorage()->read();
      $this->view->storage= $storage;
}
视图中的

<?php echo $this->escape($this->storage->username); ?>