2014-02-08 166 views
0

我在與會話處理問題值2Zend框架2不能在Zend框架檢索會議

爲什麼$會話級>帶寬alwas「空」在fileAction在beaconAction設置之後?

public function fileAction() { 
    $session = new SessionContainer(); 
    $bandwidth = $session->bandwidth; 
    var_dump($session->bandwidth); 
    die; 
    $settings = $this->getSettings(); 
    $this->lightbox($this); 
    return new ViewModel(array(
     'file' => $this->getEvent()->getRouteMatch()->getParam('file'), 
     'film_path' => $settings['film_path'], 
     'poster_file' => $settings['poster_file'], 
    )); 
} 

public function beaconAction() { 
    $session = new SessionContainer(); 
    $bandwidth = $this->getRequest()->getQuery('bw'); 
    $session->bandwidth = $bandwidth; 
    var_dump($session->bandwidth); 
    return new ViewModel(array(
     'bandwidth' => $bandwidth 
    )); 
} 
+0

同在這裏:http://www.zfforum.de/zf2-einsteigerfragen/12816- session-immer-null.html – nofreeusername

回答

0

也許嘗試設置會話容器的命名空間,並檢查您的查詢數據 http://framework.zend.com/manual/2.2/en/modules/zend.session.container.html#basic-usage

public function fileAction() { 
    $session = new SessionContainer("mybeaconsession"); // <--- this 
    $bandwidth = $session->bandwidth; 
    var_dump($session->bandwidth); 
    die; 
    $settings = $this->getSettings(); 
    $this->lightbox($this); 
    return new ViewModel(array(
     'file' => $this->getEvent()->getRouteMatch()->getParam('file'), 
     'film_path' => $settings['film_path'], 
     'poster_file' => $settings['poster_file'], 
    )); 
} 

public function beaconAction() { 
    $session = new SessionContainer("mybeaconsession");  // <-- try this 
    $bandwidth = $this->params('bw');      // <-- try this 
    $session->bandwidth = $bandwidth; 
    var_dump($session->bandwidth); 
    return new ViewModel(array(
     'bandwidth' => $bandwidth 
    )); 
} 
+0

OP已經在德國zf論壇上回答了他/她自己的問題。他/她錯過了接受餅乾。 – nofreeusername