I have a login script that created cookies when the user logs in. I also have the following if statement to change the buttons in the navigation bar if a user is signed in:
<?php
if (isset($_SESSION['user_id'])) {
echo "<li><a href='logout.php' class='btn btn-default navbar-btn' role='button'>Log Out</a></li>";
echo "<li><a href='myaccount.php' class='btn btn-default navbar-btn' role='button'>Dashboard</a></li>";
echo "<li><a href='newlisting.php' class='btn btn-default navbar-btn' role='button'>Add New Listing</a></li>";
} else {
echo "<li><a href='login.php' class='btn btn-default navbar-btn' role='button'>Log In</a></li>";
echo "<li><a href='signup.php' class='btn btn-default navbar-btn' role='button'>Sign Up</a></li>";
}
?>
However, when I log in, I get the following error:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/kizumit/public_html/header.php:54) in /home/kizumit/public_html/dbc.php on line 40
I'm able to log in and I stay logged in, but the buttons aren't changing. I'm wondering if there is a way for me to change the buttons based on a user being logged in, without interfering with the cookies that are being created when the user logs in. Any suggestions?