Thursday 6 March 2014

[PHP] [CentOS] Session not saved when using PHP from remi repository


I encountered this issue when using Nginx + PHP + Memcache installed from remi repository (compile? nope). Any session ($_SESSION) is not saved, and removed in the next page load.

Note: The default session save path folder is used in this tutorial. You need to check out yours inside by using phpinfo()and look for session.save_path value.

To solve this, the process is surprisingly easy. You only need to chmod /var/lib/php/session to 777, and everything will work great.
chmod 777 /var/lib/php/session
 If problem persists, try chown-ing the session folder to the specific web server user. (Exactly not root) This is a example for Nginx, linked to user nginx.
chown nginx /var/lib/php/session
Same issue? Remove all files inside /var/lib/php/session folder.
rm /var/lib/php/session/* -f