系统上的PHP是编译安装的,在session_start()的时候报错!
A 错误信息:
Warning: session_start(): open(/var/lib/php/session/sess_qavhhacl7lrdbggauasf1qdlo5, O_RDWR) failed: No such file or directory (2) in /www/tool/classes/service/User.php on line 75
1
Warning: Unknown: open(/var/lib/php/session/sess_qavhhacl7lrdbggauasf1qdlo5, O_RDWR) failed: No such file or directory (2) 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
B 查看php.ini:
session.save_path = "/var/lib/php/session" // session的存放路径
所以上面的文字是提示没有该目录
C 解决问题:
创建上面的目录
mkdir session
chmod -R 777 session
再次运行程序就OK了
D 查看更多:
(1)
pwd
/var/lib/php/session
? session ls
sess_qavhhacl7lrdbggauasf1qdlo5
(2)
用firebug查看cookie:
PHPSESSID qavhhacl7lrdbggauasf1qdlo5 // php.ini session.name = PHPSESSID
编译安装PHP使用session_start()时报错&解决办法