AKalair Posted September 21, 2008 Share Posted September 21, 2008 Hi guys, Everything was working fine earlier but I made some changes to the layout and now I'm getting this error. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/thegamer/public_html/PHP/members.php:3) in /home/thegamer/public_html/PHP/members.php on line 4 ERROR: You must be logged in to view this This is the code <html> <head> <?php session_start(); if (!$_SESSION['auth'] == 1) { // check if authentication was performed // else die with error die ("ERROR: You must be logged in to view this"); } ?> <link rel="stylesheet" type="text/css" href="css.css" /> <title>Aarons Site</title> </head> <body> <div id="navigation"> <p class="headings">Navigation</p> <p><a href="index.html">Home</a></p> <p><a href="newuser.html">Register</a></p> <p><a href="login.html">Log In</a></p> <p><a href="members.php">Members Area </a></p> </div> <div id="content">Content Section <form action="logout.php" method="post"> <input type="submit" value="Logout" /> </form> </div> <div id="banner"> <p>Banner</p> <p> </p> <p> </p> </div> </body> </html> Its meant to just display either welcome your logged in or, ERROR: You must be logged in to view this. Link to comment https://forums.phpfreaks.com/topic/125193-solved-php-session-error/ Share on other sites More sharing options...
wildteen88 Posted September 21, 2008 Share Posted September 21, 2008 You cannot have any form of output before the use of session_start(). Change <html> <head> <?php session_start(); if (!$_SESSION['auth'] == 1) { // check if authentication was performed // else die with error die ("ERROR: You must be logged in to view this"); } ?> to <?php session_start(); if (!$_SESSION['auth'] == 1) { // check if authentication was performed // else die with error die ("ERROR: You must be logged in to view this"); } ?> html> <head> Link to comment https://forums.phpfreaks.com/topic/125193-solved-php-session-error/#findComment-647117 Share on other sites More sharing options...
AKalair Posted September 21, 2008 Author Share Posted September 21, 2008 Thank you thats been driving me nuts Link to comment https://forums.phpfreaks.com/topic/125193-solved-php-session-error/#findComment-647118 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.