PHP 警告权限在 session_start() 上被拒绝 (13)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6821532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:22:39  来源:igfitidea点击:

PHP Warning Permission denied (13) on session_start()

phpsessionwarnings

提问by Basic Bridge

Possible Duplicate:
How can I fix the Permission error when I call session_start()?

可能重复:
如何在调用 session_start() 时修复权限错误?

I'm getting the following error:

我收到以下错误:

PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: open(/tmp/sess_49a20cbe1ef09a2d0262b3f7eb842e7b, O_RDWR) failed: Permission denied (13) in /home/------/public_html/includes/libs/ss.inc.php on line 1

The problem doesn't happen all the time, but comes and goes.

问题并非一直发生,而是来来去去。

This the code at line on 1 in ss.inc.php

这是 ss.inc.php 中第 1 行的代码

<?php session_start(); ?>

回答by Peter Rowell

You don't appear to have write permission to the /tmpdirectory on your server. This is a bit weird, but you can work around it. Beforethe call to session_start()put in a call to session_save_path()and give it the name of a directory writable by the server. Details are here.

您似乎没有/tmp对服务器上的目录的写权限。这有点奇怪,但你可以解决它。之前调用session_start()投入到呼叫session_save_path(),并给它由服务器写入的目录的名称。详细信息在这里

回答by marcelog

do a phpinfo(), and look for session.save_path. the directory there needs to have the correct permissions for the user and/or group that your webserver runs as

执行 phpinfo(),然后查找 session.save_path。那里的目录需要对您的网络服务器运行的用户和/或组具有正确的权限

回答by Phil

I have had this issue before, you need more than the standard 755or 644permission to store the $_SESSIONinformation. You need to be able to write to that file as that is how it remembers.

我以前遇到过这个问题,您需要的不仅仅是存储信息的标准755644权限$_SESSION。您需要能够写入该文件,因为它是这样记住的。

回答by Dor

It seems that you don't have WRITE permission on /tmp.

您似乎没有 WRITE 权限/tmp

Edit the configuration variable session.save_pathwith the function session_save_path()to 1 directory abovepublic_html(so external users wouldn't access the info).

使用函数session_save_path()将配置变量session.save_path编辑到上面的 1 个目录(因此外部用户不会访问信息)。public_html

回答by Dor

PHP does not have permissions to write on /tmp directory. You need to use chmodcommand to open /tmp permissions.

PHP 无权写入 /tmp 目录。您需要使用chmod命令来打开 /tmp 权限。