“无法发送会话缓存限制器-标头已发送" [英] "Cannot send session cache limiter - headers already sent"

查看:98
本文介绍了“无法发送会话缓存限制器-标头已发送"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

会话出现问题,这变得非常烦人.每次尝试在特定页面上启动会话时,都会出现以下错误:

Having a problem with sessions which is becoming very annoying. Every time I try to start a session on a particular page I get the following error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at ............ on line 23

使用此代码:

<?php
session_start();
if(isset($_SESSION['user']))
    {
        $user = $_SESSION['user'];
        echo "$user";
    }
else
    {
    }
?> 

是否暗示我已经使用过session_start();?香港专业教育学院环顾四周,但没有什么可以真正解决这个问题.

Is it suggesting I've already used session_start(); ? Ive had a look around but nothing really clears this up for me.

谢谢

推荐答案

标头已发送"表示您的PHP脚本已经发送了HTTP标头,因此它现在无法对其进行修改.

"Headers already sent" means that your PHP script already sent the HTTP headers, and as such it can't make modifications to them now.

在致电session_start之前,请确保您没有发送任何内容.更好的是,只需将session_start作为您在PHP文件中要做的第一件事(因此,请绝对将其放在所有HTML等之前的开头).

Check that you don't send ANY content before calling session_start. Better yet, just make session_start the first thing you do in your PHP file (so put it at the absolute beginning, before all HTML etc).

这篇关于“无法发送会话缓存限制器-标头已发送"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆