我正在尝试学习如何使用ZF2 / Doctrine的会话作为登录表单。 The documentation列出了用于访问SESSION变量的Container和Session Storage。但是我使用哪个?我如何使用会话存储?
答案 0 :(得分:2)
据我所知: Zend \ Session \ Container as SessionContainer; ArrayObject的容器扩展意味着您可以轻松地遍历属性并读取/写入它们,例如
use Zend\Session\Container as SessionContainer;
$this->session = new SessionContainer('post');
$this->session->post_id = 1;
var_dump($this->session->post_id);
会话存储:
use Zend\Session\Storage\ArrayStorage;
use Zend\Session\SessionManager;
$populateStorage = array('foo' => 'bar');
$storage = new ArrayStorage($populateStorage);
$manager = new SessionManager();
$manager->setStorage($storage);
var_dump($manager->getStorage());