简体   繁体   中英

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM