最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
关于使用 session_start 出现的 headers 
时间:2022-07-02 10:42:19 编辑:袖梨 来源:一聚教程网
请看详细的错误程序和输出结果
echo "testing ... ";
session_start();
?>
输出为
testing ...
Warning: Cannot send session cookie - headers already sent by (output started at F:php2000test.php:2) in F:php2000test.php on line 4
Warning: Cannot send session cache limiter - headers already sent (output started at F:php2000test.php:2) in F:php2000test.php on line 4
分析:
主要原因,php.ini里有关于session 的定义,默认是使用 cookie
[session]
session.use_cookies = 1 ; whether to use cookies
这句表明使用 cookies 存储session 而 cookies的设置必须在正式 htm 之前,也就是只能在 header 里面才行,所以造成这个错误的发生
我们修改程序为
echo "testing ... ";
session_start();
?>
同样错误,因为 echo 已经输出了
我们修改程序为
$i=1;
session_start();
?>
运行正确表明在session_start的前面可以有计算语句,但是不能有输出语句
我尝试过修改
session.use_cookies = 0 ; whether to use cookies
但是没有成功,希望知道答案的朋友通知我,如何去掉cookie方式的 session
echo "testing ... ";
session_start();
?>
输出为
testing ...
Warning: Cannot send session cookie - headers already sent by (output started at F:php2000test.php:2) in F:php2000test.php on line 4
Warning: Cannot send session cache limiter - headers already sent (output started at F:php2000test.php:2) in F:php2000test.php on line 4
分析:
主要原因,php.ini里有关于session 的定义,默认是使用 cookie
[session]
session.use_cookies = 1 ; whether to use cookies
这句表明使用 cookies 存储session 而 cookies的设置必须在正式 htm 之前,也就是只能在 header 里面才行,所以造成这个错误的发生
我们修改程序为
echo "testing ... ";
session_start();
?>
同样错误,因为 echo 已经输出了
我们修改程序为
$i=1;
session_start();
?>
运行正确表明在session_start的前面可以有计算语句,但是不能有输出语句
我尝试过修改
session.use_cookies = 0 ; whether to use cookies
但是没有成功,希望知道答案的朋友通知我,如何去掉cookie方式的 session
相关文章
- 王者荣耀10周年3千点券这么花-十周年3000点券使用建议 10-13
- 明日方舟真言值得抽吗-真言抽取建议 10-13
- 永劫无间手游南宫锦武器选哪个好-南宫锦武器选择推荐 10-13
- 王者荣耀月之回廊入口在哪-月之回廊入口位置介绍 10-13
- 羊蹄山之魂的时代背景是什么 羊蹄山之魂时代故事背景介绍 10-13
- 洛克王国世界吉格斯怎么打-吉格斯打法攻略 10-13