title: Extending the life of the CakePHP Session Cookie
body: <p>In my Cake 2 app I have the following code in APP/Config/core.php:</p>
  
  <pre><code>Configure::write('Session', array(
      'defaults' =&gt; 'database',
              'cookie' =&gt; 'mycookie',
              'timeout' =&gt; 4320 //3 days
  ));
  </code></pre>
  
  <p>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.</p>
  
  <p>I got the above example from <a href="http://book.cakephp.org/2.0/en/development/sessions.html#built-in-session-handlers-configuration" rel="nofollow">http://book.cakephp.org/2.0/en/development/sessions.html#built-in-session-handlers-configuration</a></p>
  
  <p>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:</p>
  
  <p>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.</p>
  
  <p>2) User visits site on Monday and doesn't come back again until Thursday, so a new cookie has to be generated.</p>
  
  <p>At first I thought that it might be a matter of adding <code>Session.autoRegenerate</code> 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.</p>