我在网上搜索。我想在Action中使用session。我有代码:
在module.config.php中:
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.我需要把它设置为配置?