0

Yes, this question have a lot of duplicates one. But, in my code I really can't figure out where the problem is. I've done some research in another answers before I ask here, but, none is the same. Tried to look at spaces after everything. Removed that spaces, nothing work at all. The error:

<b>Warning</b>:  session_start(): Cannot send session cookie - headers already sent by (output started at /home/monyf176/public_html/borasair.com/dev/header.php:82) in <b>/home/monyf176/public_html/borasair.com/dev/adminpage.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>:  session_start(): Cannot send session cache limiter - headers already sent (output started at /home/monyf176/public_html/borasair.com/dev/header.php:82) in <b>/home/monyf176/public_html/borasair.com/dev/adminpage.php</b> on line <b>4</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/monyf176/public_html/borasair.com/dev/header.php:82) in <b>/home/monyf176/public_html/borasair.com/dev/adminpage.php</b> on line <b>7</b><br />

The line near 82 on header.php:

                </li>
            </ul>
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
</nav> -> thats one is the 82 (HTML!!!)

Start of adminpage.php:

<?php
include('header.php');
include('functions.php');
session_start();

if(!isset($_SESSION['user_email'])) { //Check if isn't logged in
    header('Location: lib/logout.php');
} else { ?> <!-- If the user are logged in display the page -->

I can't find what is wrong. I know that there are a lot of duplicate cases. But I need help with this project.

Rodrigo Schneider
  • 317
  • 2
  • 5
  • 17
  • well, duh... header.php line 82 performed output... **ANYTHING** that is not within `` code tags is considered output, and once you've performed output, you cannot issue header() calls anymore. – Marc B Dec 10 '15 at 19:59
  • have you looked on your header.php and functions.php if have another `session_start()`? – Thiago França Dec 10 '15 at 20:08
  • Marc, I can't write in header.php because it's just a html with header info. Thiago, functions and header are both clean! – Rodrigo Schneider Dec 10 '15 at 20:45

1 Answers1

3

If there is anything at the top before the <?php ?> tags, it will be considered output, thats why you get the headers are already sent. so make sure the session_start() is at the top of the page, you can make its own php tags alone and then continue with others. In simple terms, Just put session_start() at the top before you include your headers.php

William Madede
  • 727
  • 4
  • 8