How to get my session to write to apache

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 07:05:43

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

Just had the same issue on CentOS:

chown -R apache:apache /var/lib/php/session

Making the httpd user the ower of the session directory should work, as well.

daniel Warui

You probably changed a parent folder's permissions recursively, most likely to your own user.
Go to your sessions folder:
cd ~;cd /var/lib/php/

If you find a sessions folder, just write these two commands in your terminal:
cd ~; to go home, then
sudo chown -R www-data:www-data /var/lib/php/session

Or, if your sessions folder is "sessions" instead of "session":
cd ~; to go home, then
sudo chown -R www-data:www-data /var/lib/php/sessions

This way your server will be able to write sessions into your project.
I'm Quite sure about this approach.

Muharrem

both of tmp and /var/lib/session must be chmod 1777

and problem solved.

Try changing the owner of the session directory to www-data. To do this run this command sudo chown -R www-data /var/lib/php/sessions. This works for me.

on ubuntu 12.04 /var/lib/php5 has 1733 permission I change in php.ini session.save_path to /tmp to correctly store sessions alternatively you can set parameter in your code by ini_set('session.save_path',path_where_apache_have_permission_777);

carla

I tried all the solutions here but they didn't work, because php.ini was being overwritten by other configs.

To find the culprit I used this trick:

grep -lR 'php_value' /etc/

And there it was /etc/httpd/conf.d/php.conf messing it up. So I changed its value from php_value session.save_path "/var/lib/php/session" to php_value session.save_path "/tmp".

After restarting Apache (service httpd restart) it finally worked!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!