1

我在网上搜索。我想在行动中使用会话。我有代码:

在 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。我需要像 config 一样设置它吗?

4

0 回答 0