在我的send.php
文件的最顶端有以下内容:
ob_start();
@session_start();
//some display stuff
$_SESSION['id'] = $id; //$id has a value
header('location: test.php');
在我的test.php文件的最顶部有以下内容:
ob_start();
@session_start();
error_reporting(E_ALL);
ini_set('display_errors', '1');
print_r($_SESSION);
当数据发送到test.php
时,将显示以下内容:
Array ( )
警告:未知: open(/var/lib/php/session/sess_isu2r2bqudeosqvpoo8a67oj02,O_RDWR)失败:在第0行的未知中权限被拒绝(13
警告:未知:无法写入会话数据(文件)。请验证第0行的未知会话中session.save_path的当前设置(/var/lib/php/session)是否正确
我只尝试使用session_start();但结果都是一样的。
发布于 2011-02-24 19:40:15
看看你的留言
所以它与权限相关的第一件事是
open(/var/lib/php/session/sess_isu2r2bqudeosqvpoo8a67oj02,
O_RDWR)失败:在第0行的未知中权限被拒绝(13
您必须检查此/var/lib/php/session/
的文件权限更改模式
与session.save_path
相关的第二件事是 it it
警告:未知:无法写入会话数据(文件)。请验证第0行的未知会话中session.save_path的当前设置(/var/lib/php/session)是否正确
在php.ini中
[Session]
; Handler used to store/retrieve data.
session.save_handler = files
; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
;
; As of PHP 4.0.1, you can define the path as:
;
; session.save_path = "N;/path"
;
; where N is an integer. Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories. This is useful if you
; or your OS have problems with lots of files in one directory, and is
; a more efficient layout for servers that handle lots of sessions.
;
; NOTE 1: PHP will not create this directory structure automatically.
; You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
; use subdirectories for session storage
;
session.save_path = /tmp/ <= HERE YOU HAVE TO MAKE SURE
; Whether to use cookies.
session.use_cookies = 1
发布于 2011-02-24 19:36:37
您必须将session.save_path
设置更改为可访问的目录,例如/tmp/
如何改变:http://php.net/session_save_path
在共享主机上,建议将会话保存路径设置在主目录内但在文档根目录下
还要注意的是
运算符使用ob_start在这里是不必要的,
发布于 2012-06-14 22:14:05
这是PHP版本中的known bug。根据您的服务器环境,您可以尝试将会话文件夹设置为777:
/var/lib/php/session
(您的位置可能会有所不同)
我最终使用了这个变通方法:
session_save_path('/path/not/accessable_to_world/sessions');
ini_set('session.gc_probability', 1);
您必须创建此文件夹并使其可写。我并没有太多地摆弄权限,但777对我来说(显然)是有效的。
确保您存储会话的位置不会被世界访问。
这个解决方案可能并不适用于所有人,但我希望它能帮助一些人!
https://stackoverflow.com/questions/5104065
复制相似问题