警告:session_start():失败:权限被拒绝(13)

时间:2014-11-20 12:27:23

标签: php session

我收到错误:

Warning: Unknown: open(/tmp/sess_beaac196b5082a77131f957bcfa35ee7, 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 (/tmp) in Unknown on line 0

我检查了/ tmp目录并且它是可写的(使用此代码):

$filename = '/tmp';
if (is_writable($filename)) {
    echo 'The file is writable';
} else {
    echo 'The file is not writable';
}

php.ini文件说session.save_path是/ tmp

我有什么明显的遗失吗?

编辑:我尝试过设置一个新的会话路径,但即使在CHMOD 777之后它也会告诉我:

Warning: session_start(): open(/sessions/sess_beaac196b5082a77131f957bcfa35ee7, O_RDWR) failed: No such file or directory (2) 

2 个答案:

答案 0 :(得分:3)

在页面开始时使用session_save_path()

参考:http://php.net/manual/en/function.session-save-path.php

答案 1 :(得分:0)

我最终设法将新文件夹的完整路径放在..

session_save_path('/home/scittwebhost/sessions');

我仍然不知道为什么我不能写/tmp - 权限是777

全部谢谢