CakePHP 3如何增加会话超时时间

3

有人知道如何在CakePHP 3中增加会话超时时间吗?无论我尝试了什么,它都只在15分钟后超时。

我最近尝试的是在app.php文件中更改此设置,但它仍然在大约15分钟后超时,这非常令人沮丧。

'Session' => [
        'defaults' => 'php',
            'timeout'=>300*60//in minutes
    ],

谢谢您。
1个回答

3

有“会话超时”和“会话cookie生存时间”两种情况。后者不受前者影响,在CakePHP配置中可以进行配置,如您的代码片段所示,并由CakePHP的会话处理程序处理。

检查您的PHP安装中的“session.cookie_lifetime”设置,它可能是问题的原因。如果您需要更改它,请在您的“php.ini”中进行更改,或使用CakePHP会话配置中的“ini”选项。

引用自文档:

By default PHP sets the session cookie to expire as soon as the browser is closed, regardless of the configured Session.timeout value. The cookie timeout is controlled by the session.cookie_lifetime ini value and can be configured using:

Configure::write('Session', [
    'defaults' => 'php',
    'ini' => [
        // Invalidate the cookie after 30 minutes without visiting
        // any page on the site.
        'session.cookie_lifetime' => 1800
    ]
]);

The difference between Session.timeout and the session.cookie_lifetime value is that the latter relies on the client telling the truth about the cookie. If you require stricter timeout checking, without relying on what the client reports, you should use Session.timeout.

食谱 > 会话 > 会话配置

如果这不能解决问题,您需要进行一些调试工作:检查会话cookie的过期值,钩入CakePHP的会话处理程序以确定是否是会话被终止的原因 (\Cake\Network\Session::_timedOut()) 等等...


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接