Reputation: 489
Once my users login, i create a PHP session for them and store the user id in the session. But sometimes the user's session times-out and the time is not really predictable as it happens at different times. A user is sometimes doing something on the site which takes time before they press save at this point the session times out.
I have a jQuery keepAlive function that calls a file name keepAlive.php every x amount of seconds. But not sure what code to put in the php file to keeep the php session alive. Any ideas? Should i just do start_session() and thats it?
Thanks
Upvotes: 0
Views: 4207
Reputation: 424
The lack of the predictability has to do with your garbage collection settings (see http://www.php.net/manual/en/ref.session.php for the long description). But the killing of old sessions happens by a random chance that then kills every session older than a certain time.
to start the session all you need is start_session()
but if you need things to last longer then you should probably change your php.ini to extend how long it starts before they get killed. (session.gc_maxlifetime)
Upvotes: 1