• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Session files

I've noticed that in my writable/sessions directory there are a zillion files. Do these keep accumulating or are they deleted at some point?
Simpler is always better

It's handled by PHP's own garbage collection routine, which by default on many systems run every 100th request. It's possible there's a bug in the system, but largely dependent on what OS you're running and your server settings. Here's a decent explanation of what's going on and ways to work with it, even though it uses Symfony and Laravel for examples.

When GC happens, this should be ran.

Clean up is determined by the PHP runtime configuration items gc_probability divided by gc_divisor. That ratio defines the probability that the GC (garbage collection) process is started on any session initialization. So, given 1/100 there is a 1% chance that the GC process starts. (docs)

I've highlighted probability and chance to point out there is no guarantee GC will happen once every 100 times per the 1/100 example. It could happen twice in a row and then not again for 200 (and potentially many more) session initializations.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.