0

There are 3 settings which affect the life time of PHP sessions, which can be set in php.ini or in .htaccess. A sample from .htaccess is:

#   Sessions
    php_value   session.gc_probability 1
    php_value   session.gc_divisor 100
    php_value   session.gc_maxlifetime 600

I understand that this means that after 600 seconds, the session may be destroyed. The probability and divisor settings are supposed to determine how soon.

I also understand that this means that the session above has 1 in 100 chance of being destroyed; the divisor should be lower for quiet servers and higher for busy servers to balance between overworking the server and destroying the session in a timely fashion.

The question is why are there both settings? I have never seen the probability setting to anything other than 1.

Manngo
  • 14,066
  • 10
  • 88
  • 110

1 Answers1

0

session.gc_divisor coupled with session.gc_probability defines the probability that the gc (garbage collection) process is started on every session initialization. The probability is calculated by using gc_probability/gc_divisor, e.g. 1/100 means there is a 1% chance that the GC process starts on each request. session.gc_divisor defaults to 100.

Documentation:

http://php.net/manual/en/session.configuration.php#ini.session.gc-divisor

Kevin Yan
  • 1,236
  • 11
  • 19