In my Cake 2 app I have the following code in APP/Config/core.php:
Configure::write('Session', array(
'defaults' => 'database',
'cookie' => 'mycookie',
'timeout' => 4320 //3 days
));
This is working mostly as expected. The sessions are stored in the database, the cookie is named correctly and the cookie is deleted after 3 days.
I got the above example from http://book.cakephp.org/2.0/en/development/sessions.html#built-in-session-handlers-configuration
Unfortunately, this isn't exactly what I want. I want the cookie to be deleted after 3 days, but I want it to be 3 days after the last time the user was active on the site. In other words:
1) User visits site on Monday, cookie is set to expire Wednesday. However, he comes back on Tuesday so now the cookie will expire on Thursday.
2) User visits site on Monday and doesn't come back again until Thursday, so a new cookie has to be generated.
At first I thought that it might be a matter of adding Session.autoRegenerate
but that doesn't seem to be of any help. Even with this set, the cookie still seems to suffer the same fate of being deleted after 3 days even if the user was active on the site for the entire 3-day period.