Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP Session Timeout on Inactivity only

Tags:

So the crux of this question is just how to prevent CakePHP from de-authenticating a session ONLY after a period of inactivity.

So, if the user does nothing then I expect CakePHP to log them out after a period of 30 minutes. However, if the user chooses to visit a page on the 28th minute of inactivity, then CakePHP should 'reset' it's timeout counter.

This currently isn't happening. Regardless of activity, CakePHP times out after the specified time in my core configuration (app/Config/core.php).

Here's my config code:

Configure::write('Session', array(     'defaults' => 'cake',     'timeout' => '30' )); 

Any ideas?

like image 447
Kyle O'Brien Avatar asked Jan 22 '13 23:01

Kyle O'Brien


1 Answers

After running into the same problem I've found that this was caused by the Session.cookieTimeout value. Although the php session was still valid, the expiration date on the session cookie does not get refreshed.

This is now my session config

Configure::write('Session', array(         'defaults' => 'php',         'timeout' => 30, // The session will timeout after 30 minutes of inactivity         'cookieTimeout' => 1440, // The session cookie will live for at most 24 hours, this does not effect session timeouts         'checkAgent' => false,         'autoRegenerate' => true, // causes the session expiration time to reset on each page load     )); 
like image 155
Rob Forrest Avatar answered Sep 20 '22 15:09

Rob Forrest