PHP Session Timeout Problems

August 28, 2009

Users of our website were being timed out when they stopped using their computer for an extended period of time(Whether being interrupted by someone or going to the bathroom, you get the idea). This caused issues when they tried to pick up where they left off when taking one of our courses.

For example, if they were lucky and selected another php page, the session variable was checked and they were automatically logged out. But if they tried to launch a new course from the current php page, the player would be launched and indicate that the page could not be found which was misleading. The user had actually been timed out.

In other words, the desired timeout response was only triggered if the page was refreshed or a new page was loaded, otherwise a user would get misleading http response messages.

I finally found the following blog entry explanation The Quest to Conquer the PHP Session Timeout which provided the solution I needed.

Solution: modification of the session.gc_maxlifetime variable value.

In the php.ini file I changed the value of
session.gc_maxlifetime = 1440
to:
session.gc_maxlifetime = 86400

Solution to problem, changing the php default session timeout from 24 minutes to 24 hours.