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

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

问题描述

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

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.

谢谢

推荐答案

"Headers already sent" 意味着你的 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天全站免登陆