I have changed my website to run PHP as CGI/FastCGI. Now session cookies are not saved, why is this?




In CGI or FastCGI mode, PHP runs with the permissions of the domain's FTP user.

PHP support mode can be configured for each domain on the "Web Hosting Settings" page found at Domains -> domain.tld -> Web Hosting Settings:


Also following PHP warnings can appears:

Warning: session_start() [function.session-start]: open(/var/lib/php/session/sess_vr12g68afa365jenb96han4k24, O_RDWR) failed: Permission denied (13) in /var/www/vhosts/<domain>/httpdocs/<script>.php on line <N>
Warning: Unknown: open(/var/lib/php/session/sess_vr12g68afa365jenb96han4k24, O_RDWR) failed: Permission denied (13) in Unknown on line 0
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0


In Parallels Plesk Panel versions prior to 10.4, PHP configuration is set in the /etc/php.ini file and by default has the session path set as follows:

~# grep session.save_path /etc/php.ini
session.save_path = "/var/lib/php/session"

The default permissions value for this directory is 770:

~# ls -ld /var/lib/php/session
drwxrwx--- 2 root apache 65536 Dec 16 07:48 /var/lib/php/session


As the PHP scripts are processed in CGI/FastCGI mode under the <ftpuser>:psacln account, the process cannot read/write that directory and it will, effectively, pick up the session file.


1. Upgrade Parallels Plesk Panel to version 10.4 (if not already running v10)

2. Create a subdirectory under the domain's private directory:

~# mkdir /var/www/vhosts/domain.tld/private/php_sess
~# chown <ftpuser>:psacln /var/www/vhosts/domain.tld/private/php_sess
~# chmod 0700 /var/www/vhosts/domain.tld/private/php_sess

4. Edit the customized PHP configuration in Plesk overriding the session.save_path directive:

Plesk > Domains > domain.com > Websites & Domains > domain.com > PHP Settings

Set the session.save_path parameter to '/var/www/vhosts/domain.com/private/php_sess'

Last update:
2013-02-21 15:43
Nick Fawbert
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category