Child pages
  • The clean_user_php_sessions Script
Skip to end of metadata
Go to start of metadata

Overview

Use the /usr/local/cpanel/scripts/clean_user_php_sessions script to purge expired PHP sessions from a secure temporary directory. This script checks the session.gc_maxlifetime and 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_maxlifetime PHP configuration value for each version of PHP. If this script detects different values in the session.gc_maxlifetime variable, 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.

For more information about PHP session files, read our MultiPHP INI Editor for WHM documentation.

Notes:

  • This script requires root-level permission.
  • We recommend that this script runs at least once per day to remove old PHP session files.
  • When the /usr/local/cpanel/scripts/maintenance script runs, it adds the /usr/local/cpanel/scripts/clean_user_php_sessions script to the root user's crontab.
  • If you customize the session.gc_maxlifetime value, but do not customize the session.save_path value, the script does not use the session.gc_maxlifetime variable value.

The /usr/local/cpanel/scripts/clean_user_php_sessions script

When you run this script, the system only removes files with the session.save_path variable in a sess_* format by default.

Arguments

This script does not accept any arguments.

Custom PHP sessions

To remove custom PHP session save handlers, run this script with a Perl Compatible Regular Expression (PCRE). For example, run the following command to clear out all PHP session files that match the custom example_session_* format:

/usr/local/cpanel/scripts/clean_user_php_sessions example_session_*

Important:

Make certain the provided regular expression is specific so you do not remove any misconfigured session.save_path variables.

Additional information

  • No labels