我想从 layout.xml 访问会话值。
我做的代码是
布局.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;
主页/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 中获取会话值。
期待积极的帮助。