daveeboi Posted July 16, 2008 Share Posted July 16, 2008 From my script for a successful login on my site : // Check if session is not registered , redirect back to main page. <? session_start(); if(!isset($_SESSION['myusername'])){ header("location:index.php"); } else { echo"Login Successful"; } ?> I keep getting the following output : // Check if session is not registered , redirect back to main page. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/html/login_success.php:3) in /home/content/html/login_success.php on line 4 Warning: Cannot modify header information - headers already sent by (output started at /home/content/html/login_success.php:3) in /home/content/html/login_success.php on line 6 The page does not redirect to the pages I wish it to and it displays warnings that I can't seem to get rid of. Any advice please? Link to comment https://forums.phpfreaks.com/topic/114954-page-redirection-and-eliminating-warnings/ Share on other sites More sharing options...
xtopolis Posted July 16, 2008 Share Posted July 16, 2008 Without seeing if this is a page in itself or not, I would say remove the whitespace. Basically make the file like this: <? session_start(); // Check if session is not registered , redirect back to main page. if(!isset($_SESSION['myusername'])){ header("location:index.php"); } else { echo"Login Successful"; } ?> Notice there is no blank line before the <? tag. also I just moved the comment below the session. However if that code is actually below other code in the page, we would need to see that. Header errors are almost always caused by unintended whitespace being show before php parses the script. Link to comment https://forums.phpfreaks.com/topic/114954-page-redirection-and-eliminating-warnings/#findComment-591231 Share on other sites More sharing options...
daveeboi Posted July 16, 2008 Author Share Posted July 16, 2008 Thanks, that's got rid of the warnings and taken to a new page. Unfortunately it's also taking my test login members as a failed login as well but that's in my checklogin.php file so off to try fix that now. This forum is great for quick and reliable help, can't believe I've just found it. Link to comment https://forums.phpfreaks.com/topic/114954-page-redirection-and-eliminating-warnings/#findComment-591503 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.