Zend framework2 如何在控制器操作中使用会话容器?
我在网上搜索。我想在行动中使用会话。我有密码: 在module.config.php中:Zend framework2 如何在控制器操作中使用会话容器?,zend-framework2,session-timeout,Zend Framework2,Session Timeout,我在网上搜索。我想在行动中使用会话。我有密码: 在module.config.php中: return array( 'remember_me_seconds' => 360, 'name' => 'zf2', 'use_cookies' => true, 'cookie_httponly' => true, ), ); 在Module.
return array(
'remember_me_seconds' => 360,
'name' => 'zf2',
'use_cookies' => true,
'cookie_httponly' => true,
),
);
在Module.php中
public function onBootstrap(MvcEvent $e)
{
$config = $e->getApplication()->getServiceManager()->get('Configuration');
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions($config['session']);
$sessionManager = new SessionManager($sessionConfig);
$sessionManager->start();
/**
* Optional: If you later want to use namespaces, you can already store the
* Manager in the shared (static) Container (=namespace) field
*/
Container::setDefaultManager($sessionManager);
}
在控制器中:
public function updatesessionAction(){
$key = $this->getEvent()->getRouteMatch()->getParam('key');
$value = $this->getEvent()->getRouteMatch()->getParam('value');
$this->userSession = new Container($this->sessionNameSpace);
$this->userSession->offsetSet($key,$value);
}
它运行,但过期时间始终=180秒。不像我配置的360秒。
我不知道在哪里有180的价值。我需要做什么才能将其设置为config