seb
seb

Reputation: 313

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

I read the answers here How to fix "Headers already sent" error in PHP but this not fix my error.

i don't understand, session_start() is the first thing i call in my files and I am using the UTF-8 without BOM encoding. But i still get this php warning.

Error :

PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /home/feyzprod/public_html/nearby/register.php:1) in /home/feyzprod/public_html/nearby/register.php on line 1

My file encoding is

Encoding is UTF-8 without BOM

Code :

<?php session_start();
    require_once('bdservice.php');
    require_once('script.php');

    $bd = new BDService();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

<title>NearBy Me : Courtier immobiliers</title>

<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/ico.css" />
<link rel="stylesheet" href="https://formoid.net/forms/30/17477/formoid-default-skyblue.css" type="text/css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://formoid.net/lib/iframe.js"></script>
<link rel="stylesheet" href="https://formoid.net/lib/form.css" type="text/css" />

<script>

</script>

</head>

<body>
    <div class='bar'>
        <div class='header'>
            <div id='left'></div>

            <div id='right'>
                <div style='margin-top:35px;'>
                <span><a href='#'>Français</a> | <a href='#'>Anglais</a></span><br/><br/>
                <?php
                    if(isset($_SESSION['authentification']))
                    {
                        echo "<a href='profil.php'><button class=\"large green button\">Profil</button></a>";
                    }
                    else
                    {
                        echo "<a href='connexion.php'><button class=\"large green button\">Login</button></a>";
                    }
                ?>
                </div>
            </div>

            <div style='clear:both;'></div>
        </div>
    </div>

    <div class='inscription'>
        <img src='images/inscription.png' alt='inscription' title='inscription' /><br/><br/>
            <?php
                if(!isset($_POST['Valider']))
                {

Upvotes: 2

Views: 3172

Answers (1)

doublesharp
doublesharp

Reputation: 27637

You probably have a space or other whitespace character at the beginning of /home/feyzprod/public_html/nearby/register.php, indicated in your error that it is on line 1.

The space will echo to the output which means that you can no longer write to the headers, which is where PHP wants to set the session information via a cookie.

Upvotes: 3

Related Questions