我在Zend Framework 2中遇到会话处理问题
在beaconAction中设置后,为什么$ session->带宽在fileAction中为'null'?
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 :(得分: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
));
}