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条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效