Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question
up vote 0 down vote accepted

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.

share|improve this answer
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. – Ronnie Jespersen May 24 '12 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. – Ronnie Jespersen May 24 '12 at 13:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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