当我使用会话将值从一个页面发送到另一个页面时,出现以下错误 [英] when I send value from a page to another page using session, the following error appears
问题描述
警告:session_start():打开(/var/cpanel/php/sessions/ea-php56/sess_c84fdb91458e26c7325faf74a529a3,O_RDWR) 失败: 中没有这样的文件或目录 (2)/home/username/public_html/test2.php 第 3 行
Warning: session_start(): open(/var/cpanel/php/sessions/ea-php56/sess_c84fdb91458e26c7325faf74a529a3, O_RDWR) failed: No such file or directory (2) in /home/username/public_html/test2.php on line 3
警告:session_start():无法读取会话数据:文件(路径:/var/cpanel/php/sessions/ea-php56) 在/home/username/public_html//test2.php 第 3 行
Warning: session_start(): Failed to read session data: files (path: /var/cpanel/php/sessions/ea-php56) in /home/username/public_html//test2.php on line 3
注意:未定义索引:username in/home/username/public_html/test2.php 第 4 行
Notice: Undefined index: username in /home/username/public_html/test2.php on line 4
我使用了 此代码 但添加
(error_reporting(E_ALL);
ini_set('display_errors', 1);)
到test2.php
推荐答案
您在服务器上的会话目录 /var/cpanel/php/sessions/ea-php56/
可能不存在或您不存在获得访问权限.
Your session directory /var/cpanel/php/sessions/ea-php56/
on sever may be not exist or you do not have permissons to access to it.
如果没有适当的权限,则创建目录或更改 php.ini 文件中的会话目录.如果您无权访问服务器,请联系您的服务提供商.
Create directory if not exist with proper permissions or change session directory in php.ini file. If you dont have access to server contact your service provider.
您可以在访问或创建会话之前设置以下行以更改脚本的会话目录.
You can set below line before accesing or creating sesssion to change session directory for your script.
ini_set('session.save_path', '/path/to/your/folder')
https://www.php.net/manual/en/function.session-save-path.php
这篇关于当我使用会话将值从一个页面发送到另一个页面时,出现以下错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!