我想从layout.xml访问会话值。
我做的代码是
Layout.xml
<h2><?php $myprofile=new Zend_Session('user_session');
print $myprofile->username; ?> </h2>
索引控制器/索引操作
$userid = $this->_user->getUserId($username,$password);
$session = new Zend_Session_Namespace('user_session');
$session->username = $username;
$session->password = $password;
$session->uid = $userid;
$this->_redirect('home');
主控制器/索引操作
$this->session = new Zend_Session_Namespace('user_session');
$this->view->uname = $this->session->username;
Home/index.phtml
<?php echo "The User Name is ".$this->uname?>
但是它显示了一个错误
Fatal error: Call to protected Zend_Session::__construct() from context 'Zend_View' in/var/www/shoppingcart/application/layouts/scripts/layout.phtml on line 19
我可以在Home/index.html中获得会话值。
期待积极的帮助。
https://stackoverflow.com/questions/18963815
复制相似问题