我在Zend Framework2中的会话处理方面遇到了问题
为什么在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
));
}发布于 2014-02-10 01:07:30
也许可以尝试设置会话容器的名称空间,并检查查询数据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
));
}https://stackoverflow.com/questions/21651888
复制相似问题