How to get my session to write to apache

Daniel Kats picture Daniel Kats · Jul 8, 2011 · Viewed 63.6k times · Source

I switched servers recently, and now my home page won't work. It gives the following text:

Warning: session_start() [function.session-start]: open(/var/lib/php/session/sess_eqbchncji8kj22f0iqa9g3v7u2, O_RDWR) failed: Permission denied (13) in /var/www/vhosts/alt.alternativedc.com/httpdocs/index.php on line 6

Warning: Unknown: open(/var/lib/php/session/sess_eqbchncji8kj22f0iqa9g3v7u2, 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

I assumed that this meant that the session folder was not writable, so I ran the following command after I ssh-ed into the server:

chmod o+rw /var/lib/php/session

That didn't seem to solve the problem. Not sure what to do now...

Answer

Eddie picture Eddie · Jul 8, 2011

Try changing your session save path in your php config file, /tmp is a good location.

php.ini

session.save_path = /tmp

http://www.php.net/manual/en/session.configuration.php#ini.session.save-path