问题
Can you please let me know how to increase the session expiry time for CakePHP 2?
Currently, i set the configuration as bellow.
Configure::write('Session', array(
'defaults' => 'php',
'timeout' => 129600, // The session will timeout after 30 minutes of inactivity
'cookieTimeout' => 129600, // The session cookie will live for at most 24 hours, this does not effect session timeouts
'ini' => array(
'session.gc_maxlifetime' => 129600 // 36 hours
)
));
But, these settings not work and session expired in almost 24 minutes.Thanks This thread didn't solve my problem "How to increase cakephp Auth component session expire time"
回答1:
Add this configuration in core.php file of your application
Configure::write('Session', array(
'defaults' => 'cache',//default session
'timeout' => '<time_in_minute>',//in minutes
'cookieTimeout' => '<time_in_minute>',//in minutes
'ini' => array('session.cookie_domain' => env('HTTP_BASE')),
'handler' => array(
'config' => '<handler>' //if you are using default sessions then this field is not necessary
)
));
Add time according to your requirement
来源:https://stackoverflow.com/questions/43583718/how-to-increase-the-login-time-for-cakephp-2