kb: how-to
Question
How to manage PHP session temporary files and how often they are cleaned up from the Plesk server?
Answer
Configuring PHP to clean up these session files automatically is done by editing session.gc_probability, session.gc_divisor, and session.gc_maxlifetime PHP variables:
session.gc_probability
This setting defines the probability that the garbage collection (session cleanup) routine will be executed on each session start. It's expressed as a fraction, where the numerator is
session.gc_probability
, and the denominator is session.gc_divisor
. The default values are 1 and 100, which means there is a 1% chance that the garbage collection will run when a session starts. To increase the probability, you can set it to a higher value. For example, to make it a 10% probability, you can set session.gc_probability
to 10.session.gc_divisor
This setting represents the denominator for the probability calculation mentioned above. The default is 100, meaning that, by default, there's a 1% probability that garbage collection will run. If you set
session.gc_probability
to 10, you should leave session.gc_divisor
as 100.session.gc_maxlifetime
This setting specifies the maximum lifetime of a session in seconds. Once a session exceeds this time limit, it becomes eligible for garbage collection and will be deleted.
These variables can be edited on different levels: per domain name, per service plan or on a server level. This is where the configuration directives should be put depending on the level:
Per Domain Name
Domains > click on a Domain > PHP > Additional directives
Per Service Plan
Service plans > click on a Service plan > PHP settings > Additional directives
On the Server Level:
Tools & Settings > PHP Settings > required PHP handler > php.ini > Find the variables in question and edit their values
Comments
0 comments
Please sign in to leave a comment.