I m building an app called Trackosaur which tracks time on things you do. I m using Cake2+jQuery1.8 for this. The issue I m facing is related to sessions getting timed out. I could adjust the time that a session times out through the php ini. But I need to ‘keep alive’ a session for really long durations (10+ hours). So I setup a ajax call to a trivial function in my UserController which just uses session_start() in it.
JS
function keepAlive()
{
$.ajax({
type: 'get',
url: '/users/keepalive'
}).done(function(data){});
}
CAKE
public function keepalive()
{
session_start();
}
The ajax call is made every 10 minutes. I m not really sure if this is a good way to keep the session alive. Is there a better way I could do this using something in Cake itself as opposed to using session_start?
Many thanks for your time 🙂
In your core config file you can change the session timeout value.
In CakePHP 1.3 it’s easy. Just find this and change to your value (36000 for 10 hours).
app/config/core.php
In CakePHP 2, find this line and read the comment block above it for an explanation of how to configure the session time. I have not had to do this myself but I think: