0
我已經在我的MVC站點中設置了一個Session變量來攜帶用於任何後續頁面的id。Zend_Session不攜帶值來查看
在我的控制器中,var_dumping會話在那裏顯示正確的值,但是當我將所述值傳遞給視圖並嘗試在那裏回顯它時,它會變爲空白。
任何指示什麼正在導致他們不會出現。
請注意,該視圖是局部視圖,而不是主視圖。
引導會話相關的代碼:
protected function _initSession(){
Zend_Session::start();
$SessAuto2Auto = new Zend_Session_Namespace('SessAuto2Auto');
$SessAuto2Auto->cityIds = "1,2,3"; // Hard code values for testing purposes
$SessAuto2Auto->IndustryIds = "3,4"; // Hard code values for testing purposes
}
控制器相關的代碼:ProductController.php
public function indexAction()
{
// .. Unrelated code removed for brevity
$response = $this->getResponse();
$response->insert('sidebar', $this->view->render('sidebar.phtml'));
// This code is dumping the values correctly
echo('<pre>');
var_dump($this->sessionAuto2Auto);
echo('</pre>');
// .. Unrelated code removed for brevity
$this->view->filterCity = $this->sessionAuto2Auto['cityIds'];
$this->view->filterIndustryIds = $this->sessionAuto2Auto['IndustryIds'];
}
查看部分:sidebar.phtml
<?php
// This code does NOT show the value, comes up blank
echo($this->filterCity);
?>
感謝,有很大的幫助 – 2013-02-14 13:58:19