dqnek0079 2014-10-21 03:39
浏览 138
已采纳

session_start()在页面加载时发出警告[重复]

This question already has an answer here:

I am getting an error related to session_start() on page load.

Warning: session_start(): Cannot send session cache limiter - headers already sent

I understabd from the previous posts that we are supposed to put it right at the beginning of the page even before all HTML. So I changed my code to this:

    <?php
    if(session_id()=='')
    {
       session_start();
    }
    if (!isset($_SESSION['can_access']) || ($_SESSION['can_access'] != TRUE))
    {
       echo "Access denied";
       exit();
    }
    ?>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge chrome=1" />


 </head>
 <body>

But I still get this error. Could anyone suggest what could be done?

</div>
  • 写回答

2条回答 默认 最新

  • doulu2011 2014-10-21 03:42
    关注

    Make sure you have not output anything to the browser before you call that line, including any white space or line breaks.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)