Page 1 of 1

Keeping session data alive

Posted: Sun Jun 26, 2005 10:43 am
by snicolas
I am having a problem with a pge where users can write comments.
Some users can write REALLY long one and this can take them up to 30mn.
The problem is that when they are trying to validate their post, all session is lost due to browser inactivity (user stayed on same page).

Does anybody have a good solution for this?

thx
s

Posted: Sun Jun 26, 2005 1:22 pm
by dasil003
The simplest solution would be to extend the session lifetime by configuring session.gc_maxlifetime (either in php.ini or using ini_set()).

The more robust, but less secure solution is to serialize the SESSION array and put it in a hidden form field, then when the form is posted restore it if there is no valid session. I say less secure, because it puts all your session variables out there in the open.