会话超时不起作用+ cakephp [英] Session timeout doesn't work + cakephp
问题描述
我想将会话超时时间增加到24小时左右,为此我进行了网上搜索,但没有任何帮助。
目前,我的网站在此过期后会进行大约40分钟的会话,我希望将其设置为24小时。
在我的core.php中,添加了以下几行
I want to increase my session timeout to around 24 hours and for this I searched net but nothing helped me out. presently my website make the session of around 40 mins after this is expires i want to make this to 24 hours. In my core.php I added these lines
Configure::write('Session.timeout', '864'); // Session will last 24h
Configure::write('Session.autoRegenerate',true);
Configure::write('Security.level', 'medium');
任何想法或建议。
推荐答案
CakeSession配置参数的命名令人困惑,并且设置它们并不总是一致的(例如,参见下文)。
The naming of the CakeSession config parameters is confusing and setting them is not always consistent (see below for example).
1) Configure :: write('Session.timeout','XXX');
是会话持续的分钟分钟数。因此,如果要持续24小时,请将其设置为24 * 60。
1) Configure::write('Session.timeout', 'XXX');
is the number of minutes session will last. So if you want it to last 24 hours, set it to 24*60.
2) Configure :: write('Session.autoRegenerate' ,true);
未链接到'Session.timeout'
-即使Cake文档暗示了此链接。 autoRegenerate
取决于 CakeSession :: $ requestCountdown
值。 $ requestCountdown
是重新生成会话ID之前的综合浏览量。它不是基于时间的。
2) Configure::write('Session.autoRegenerate',true);
is not linked to 'Session.timeout'
-- even though the Cake docs implies it is. autoRegenerate
is dependent on the CakeSession::$requestCountdown
value. $requestCountdown
is the number of pageviews before the session ID is regenerated. It is NOT time-based.
因此出现了不一致:我们如何设置 CakeSession :: $ requestCountdown
值?我们处理其他参数的方式不同。您必须通过以下方式在引导程序中进行设置:
So here comes the inconsistency: how do we set the CakeSession::$requestCountdown
value? Not the same way we do the other params. You have to set it in bootstrap via:
App::uses('CakeSession', 'Model/Datasource');
CakeSession::$requestCountdown = 25;
不能像其他参数一样通过Configure来设置此值(自v2.4起)。请参阅我为此打开的票证,确认上面的内容是预期的用法: https://github.com。 com / cakephp / cakephp / issues / 2078
This value can NOT be set via Configure like the other params (as of v2.4). See the ticket I opened on this that confirms that the above is the intended usage: https://github.com/cakephp/cakephp/issues/2078
3) Configure :: write('Security.level','?? ???');
自Cake 2.0起已删除。
3) Configure::write('Security.level', '?????');
has been removed since Cake 2.0.
ref:
http://book.cakephp.org/2.0/en/development/sessions.html
这篇关于会话超时不起作用+ cakephp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!