PHP session_start fails

梦想的初衷 提交于 2019-11-27 22:22:56

问题


I'm trying to start the session in a header page in my webiste. But it seems there might be some sort of bug because it fails with the following error:

Warning: session_start() [function.session-start]: open(\xampp\tmp\sess_a7430aab4dd08d5fc0d511f781f41fe5, O_RDWR) failed: No such file or directory (2) in D:\Development\PHP\tt\Include\header.php on line 3

I'm using the default settings for xampp, everything is straight out of the box. For some reason its failing to open the file. however when i go to the directory with the session files in it, the files are there, they are just empty. Is this a bug? or am I doing something wrong?

php version 5.2.8


回答1:


This means that you don't have the correct permissions to either read or write the files in the temp directory.

If you on linux then do this

sudo chmod -R 755 \xampp\tmp //or should it be 775

On windows do this as an administrator

attrib -r -a C:\xampp\tmp /S



回答2:


First stop the Xampp Server.

session.save_path = "\xampp\tmp"

and change it to look like this

session.save_path = "C:\xampp\tmp"

Restart the Xampp Server.

That’s it now your session should work as expected.




回答3:


As Selular88 mentioned, Adding the path works and fix this issue. You can also check the path using

// This will output your current path.
echo session_save_path() ;


来源:https://stackoverflow.com/questions/670595/php-session-start-fails

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