Session timeout doesn't work + cakephp

一笑奈何 提交于 2019-12-10 19:06:19

问题


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');

any idea or sugesstion.


回答1:


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'); 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); 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.

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;

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', '?????'); has been removed since Cake 2.0.

ref: http://book.cakephp.org/2.0/en/development/sessions.html



来源:https://stackoverflow.com/questions/17673638/session-timeout-doesnt-work-cakephp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!