In select instances, a PHP web application, if not configured properly, will begin to accumulate unnecessary PHP Session files that start to grow in size and will eventually lead to maxing out a partition in disk usage.
This commonly occurs in CMS's such as WordPress or Joomla that may have plugins that do not follow efficient coding standards in deleting unused PHP Session files.
To resolve this, cPanel has developed the
clean_user_php_sessions script that will identify the session path by parsing the global
php.ini file, which would clean/remove any unused PHP session files in the configured directory.
The script checks the
session.save_path variables in the global
php.ini file and determines when to remove the PHP session files.
- This script only recognizes the global
session.gc_maxlifetimePHP configuration value for each version of PHP.
- If this script detects different values in the
session.gc_maxlifetimevariable, but the system stores the session data in a single location, the script uses the minimum value to determine when to purge expired session files.
The location of this script can be found below:
By default, the script will search for PHP session files in the following naming convention:
If your web application is configured to store the PHP session files in a different format, this would need to be adjusted by passing in a regex as the second parameter.
To learn more about the script, you can review the following documentation: