If PHP session files are not auto-cleaned on your Plesk server, they can accumulate, leading to storage issues. Here's how to resolve this issue.
Understanding PHP Session Management in Plesk
PHP sessions store temporary data for user interactions. By default, PHP session files are located in /var/lib/php/session
, and Plesk manages their cleanup through scheduled tasks. If the session folder is changed, the auto-cleaning may fail.
Step 1: Confirm the PHP Session Path
To check if the session path has been changed:
grep -ir session.save_path /opt/plesk/php/*/etc/php.ini | grep -v ";"
Solution 1: Change Back to Default PHP Session Folder in Plesk
- Log into Plesk.
- Go to Tools & Settings > PHP Settings.
- Select the PHP handler with a modified
session.save_path
value. - In the php.ini tab, set
session.save_path
to/var/lib/php/session
.
Solution 2: Create Scheduled Tasks for Custom PHP Session Directories
- Connect to the server via SSH.
- Copy the original cleanup task:
cp /etc/cron.hourly/plesk-php-cleanuper /etc/cron.hourly/php74-cleaner
- Edit the new file to reflect your custom session directory. Change the last line to:
[ -x /usr/lib64/plesk-9.0/maxlifetime ] && [ -d /var/lib/php/session ] && /usr/lib64/plesk-9.0/php_session_cleaner /var/lib/php74/session $(/usr/lib64/plesk-9.0/maxlifetime)
Disclaimer
Test any changes in a staging environment and check the latest Plesk documentation to ensure compatibility with your setup.