duanju8431 2014-02-02 20:15
浏览 29
已采纳

PHP session_start();

I'm trying to use Sessions with PHP and I started them with session_start(); at the beginning of my index.php but got following error messages:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/ideal906/public_html/index.php:1) in /home/ideal906/public_html/index.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ideal906/public_html/index.php:1) in /home/ideal906/public_html/index.php on line 2

This is strange has it's the very first line of my website:

<?php
    session_start();
?>

<!DOCTYPE html>
<html>
    <head>
<meta charset="utf-8" />
        <meta name="author" content="Pierre Anken">
        <meta name="description" content="Outil de création de menus équlibrés selon vos besoins">
        <!--[if lt IE 9]>
        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <script src="jquery.js"></script>
        <script src="scripts.js"></script>
        <link rel="stylesheet" href="style.css" />
        <title>Composez vos menus</title>
    </head>
    <body>
        <section id='sectionCentre'>
            <div id='presentation'>
                <h2>Ideal Menu</h2>

            </div>
        </section>
        <section id='bandeauHautDoite'>
            <nav>
                <ul>
                    <a href='#' elementMenu='monCompte' id='monCompte'>Mon compte</a><br/>
                    <a href='#' elementMenu='mesMenus' id='mesMenus'>Mes menus</a><br/>
                    <a href='#' elementMenu='mesRepas' id='mesRepas'>Mes repas</a><br/>
                    <a href='#' elementMenu='contact' id='contact'>Contact</a><br/>
                </ul>
            </nav>
        </section>
    </body>
</html>
  • 写回答

1条回答 默认 最新

  • douzi115522 2014-02-02 20:24
    关注

    You have an (invisible) BOM (byte-order-mark) that has been placed by your editor at the start of the file. It is being output before session_start() thus making your page unable to change the HTTP headers. Remove the BOM and the problem will go away.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器