We have a WAMP based server set up. php.ini is set up with the following:

session.gc_maxlifetime = 60*60*12
session.save_path = "d:/wamp/tmp"

The problem we are facing is that session files inside the tmp folder are being sporadically deleted and we can't tell why. Sessions will last anything from about 10 minutes to 40 minutes, when they should be lasting 12 hours.

This is a virtual host environment, but none of the code we use in these sites overrides this setting (with ini_set, apache config PHP values or otherwise) so we can't see why they are being deleted. There are also no scheduled tasks deleting the files.

Is there a way to successfully figure out why gc_maxlifetime is being ignored? For the record, I changed one of our sites to use session_save_path('D:/wamp/tmptmp'); temporarily just to double check it was the garbage collection, and session files remain in there untouched - though admittedly this doesn't give really many more clues.

  • Hi There, as I think you alluded to in your question, session files are normally cleaned up by a cron job. That said, I've only ever seen them cleaned once a day by default. However, there are two other settings of interest. gc_lifetime works with gc_probability and gc_divisor with the latter two dictating how often garbage collection occurs on session_start. I agree that if the session_lifetime is set to 12 hours, then the garbage collection should run, and not delete any sessions younger than this, but perhaps you can experiment with the above settings.
    – GeoSword
    Oct 30, 2013 at 10:18
  • Thanks GeoSword - definitely not a scheduled task, I've tried disabling all of them for testing. Also I looked in to the probability and divisor settings but as you say they shouldn't make a difference, and we couldn't make them produce any usable information to help us. Oct 30, 2013 at 10:35
  • 1
    Beware! WAMP is not designed or intended for hosting live sites. You are on your own if you do this. Nov 6, 2013 at 19:34
  • @MichaelHampton Could you possibly link to reading that explains why WAMP is not designed or intended for hosting live sites? Nov 7, 2013 at 8:49
  • 1
    Why not use a WAMP stack? WAMP stack homepages themselves also usually mention it somewhere. Nov 7, 2013 at 14:04

2 Answers 2


The configuration of session.gc_maxlifetime will determine how long before data is determined to be garbage. After that time, the session data may be deleted when "garbage collection" occurs. But that doesn't prevent the possibility of your session vars being deleted for some other reason.

Check Gumbo's answer here where he/she says "The best solution is to implement a session timeout on your own".


Faced the same problem when trying to cluster a certain project.

I discovered that the problem was caused by:



Try to delete it from your code or set the argument to false.

  • 1
    Why does this cause a problem? Is there an explanation? Nov 19, 2014 at 21:48

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