Some *Nix distributions, mainly those based on Debian, the directive session.gc_maxlifetime
is ignored when set at runtime.
This is because such linux distributions disable the PHP setando garbage collector session.gc_probability=0
.
To carry out garbage collection, the Operating System itself creates a CRONJOB, usually running every 30 minutes. This CRONJOB does the garbage collection task. To identify where and which sessions to clean, the CRONJOB script reads "php.ini". Specifically, they look for the directive session.gc_maxlifetime
. The older ones look for session.gc_probability
.
On the Internet, you will find many posts indicating session.gc_probability=0
as a solution to avoid the error described in the question. However, this does not work on newer systems. In the past the script looked for this directive however, the current ignore and search for session.gc_maxlifetime
. So it is also common to see many users who say it doesn’t work disable with session.gc_probability=0
.
For a more efficient solution, adjust the session.save_path
to another location and disable the CRONJOB created automatically by the OS.
In this case, if the chosen filter does not have a regular cleaning, the trash will accumulate. You must create your own script and run it in CRONJOB or enable the PHP collector itself session.gc_probability=1
.
To list the schedules of the user you are logged in with: crontab -l
. Enter as root and run this command to see the schedules. Then just disable the specific schedule: https://stackoverflow.com/questions/14011065/enable-disable-tasks-in-crontab-by-bash-shell
But in Centos, the correct is that Session.gc_probability is 1. If
someone knows about, what can happen if I change
to 0 on a Centos server?
Not necessarily. You can set to zero. Then you must create your own collector, as explained above.
Thank you very much. Would you know if it is possible to disable CRON by Control Panel (Plesk)? Is there any way to check if the garbage collector is configured correctly by Plesk?
– Jonatan Haas
Plesk? I didn’t see mention Plesk in the question. Anyway, it is possible as long as you can log into Plesk as root. Just go into the Scheduled Tasks and you’ll see something like this: https://i.stack.Imgur.com/c5f8n.png That green ball underneath the
S
is where turn on or off.– Daniel Omine