Keeping session data alive

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
snicolas
Forum Commoner
Posts: 97
Joined: Tue Nov 09, 2004 8:32 am

Keeping session data alive

Post 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
User avatar
dasil003
Forum Newbie
Posts: 3
Joined: Sun Jun 26, 2005 11:44 am
Location: Minneapolis

Post 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.
Post Reply