关于使用session_start出现的headersalreadysent错误的解释
2013-09-05 19:23
531 查看
请看详细的错误程序和输出结果
<html>
<?
echo "testing ... ";
session_start();
?>
</html>
输出为
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
<html>
<?
echo "testing ... ";
session_start();
?>
</html>
输出为
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
相关文章推荐
- session_start()关于Cannot send session cache limiter - headers already sent错误解决方法
- php session_start()关于Cannot send session cache limiter - headers already sent 错误解决方法
- php session_start()关于Cannot send session cache limiter - headers already sent错误解决方法
- 关于Cannot send session cache limiter - headers already sent错误解决方法
- 关于Cannot send session cache limiter - headers already sent错误解决方法
- 关于Cannot send session cache limiter - headers already sent错误解决方法
- 关于 使用post 方法出现headers already sent问题
- 关于session_start() [function.session-start]: Cannot send session cookie - headers already sent 的解决办法
- 关于Cannot send session cache limiter - headers already sent错误解决方法 【转】
- 关于Cannot send session cache limiter - headers already sent错误解决方法
- session_start():Warning Cannot send session cookie - headers already sent... 解决方法
- php中使用header函数后,页面提示:Warnging: Cannot modify header information - headers already sent by 错误的的原因
- 关于使用 session_start 出现的 Warning: session_start(): Cannot send sessioncache limiter - 问题的解决
- 如何解决"Cannot send session cache limiter – headers already sent "错误
- Warning:session_start():cannot send session cache limiter -headers already sent(output started) at
- Warning:session_start():Cannot send session cache limiter - headers already sent by
- Cannot send session cache limiter - headers already sent错误解决方法
- 出现“Cannot modify header information - headers already sent by”错误解决办法
- PHP sesion_start()或者session_regenerate_id()提示Cannot regenerate session id - headers already sent in
- session_start(): Cannot send session cookie - headers already sent