So to start of with I know that using a memcache or a database would be a better way to go. But I have (for now) made a load balance environment where I have a shared PHP session file storage. Some customers now claim they experience some problem and I am not sure if it have anything to do with the session storage.

My question is - how does PHP handle a shared php session file storage? Will there be problems with the session ID's they are given? (since its 3-4 Apache2/PHP machines running creating sessions) How about the clean up when they are marked as garbage? Can one apache2/PHP machine by "accident" delete a session not intended to be deleted yet? All the machines have the same "marked as garbage" timeout. And they all run the same PHP session clean up cronjob.


1 Answer 1


PHP does not implement "a shared php session file storage?" Do you mean you keep your session files on a network file system? Something else? The default handler uses the file modification time to determine when the session was last accessed. As long as the clocks are nearly in sync (although running ntpd makes more sense) and both are using UTC for the hardware clock then there should be no confusion.

BTW NFS file locking sucks.

  • Yes I have mounted an NFS file storage. This folder is where I keep the PHP sessions for now and that folder is shared between the backends. I know its not the best solution and it is going to be changed. May 24, 2012 at 10:29
  • Found the issue at hand. The filestorage was old and wasent hooked up on our NTP server. Causing the time to be behind with 40 minutes. May 24, 2012 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.