3

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.

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
Leonard Challis
  • 23
  • 3
  • 12
  • 26
  • 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 '13 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. – Leonard Challis Oct 30 '13 at 10:35
  • 1
    Beware! WAMP is not designed or intended for hosting live sites. You are on your own if you do this. – Michael Hampton Nov 06 '13 at 19:34
  • @MichaelHampton Could you possibly link to reading that explains why WAMP is not designed or intended for hosting live sites? – Leonard Challis Nov 07 '13 at 08:49
  • 1
    [Why not use a WAMP stack?](http://serverfault.com/q/453617/126632) WAMP stack homepages themselves also usually mention it somewhere. – Michael Hampton Nov 07 '13 at 14:04

2 Answers2

1

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".

1

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

I discovered that the problem was caused by:

/**
session_regenerate_id(true);

**/

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

grekasius
  • 2,046
  • 11
  • 15
grill
  • 11
  • 1