runnerjp Posted April 12, 2012 Share Posted April 12, 2012 Hey guys im getting the error Warning: Cannot modify header information - headers already sent by (output started at /home/kylegray/public_html/include/authenticate.php:12) in /home/kylegray/public_html/home.php on line 7 Any idea why this is coming up. I think its something to to with me setting the cookie setcookie("un", $id); but im not sure. home.php <? include("include/config.php"); //$_SESSION["backpage"]=$_SERVER['PHP_SELF']; if($_SESSION["client_log"]!="true"){ session_unregister("MemberArea"); header("Location: index.php?redirect=".basename($_SERVER['PHP_SELF'])); exit(); } ?> authenticate.php <?php include("include/required.php"); include("include/pagedetails.php"); include_once("include/authenticate.php"); $tblName = $tbluser; $id=$_SESSION["id"]; setcookie("un", $id); $ImgPath="$CatImage/"; $ImgPathsing="$SingUPImage/"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/260796-cannot-modify-header-information/ Share on other sites More sharing options...
AyKay47 Posted April 12, 2012 Share Posted April 12, 2012 One of the included files is outputting data to the client before attempting to modify the headers. This is not allowed. Quote Link to comment https://forums.phpfreaks.com/topic/260796-cannot-modify-header-information/#findComment-1336645 Share on other sites More sharing options...
Muddy_Funster Posted April 12, 2012 Share Posted April 12, 2012 isnt there a sticky about this problem? Quote Link to comment https://forums.phpfreaks.com/topic/260796-cannot-modify-header-information/#findComment-1336647 Share on other sites More sharing options...
KevinM1 Posted April 12, 2012 Share Posted April 12, 2012 See also: http://www.phpfreaks.com/forums/index.php?topic=37442.0 Quote Link to comment https://forums.phpfreaks.com/topic/260796-cannot-modify-header-information/#findComment-1336648 Share on other sites More sharing options...
PFMaBiSmAd Posted April 12, 2012 Share Posted April 12, 2012 output started at /home/kylegray/public_html/include/authenticate.php:12 ^^^ The problem is the output that your code is sending at line 12 of include/authenticate.php. Since the second piece of code you posted is including include/authenticate.php, that's probably not the code for authenticate.php since it would be pointless for a file to include itself, it also doesn't have 12 lines to it. What's the actual code for include/authenticate.php? Also, session_unregister was depreciated 10 years ago, throws a depreciated error message in php5.3, and has been completely removed in php5.4 that was just released. You would instead unset the MemberArea $_SESSION variable. Quote Link to comment https://forums.phpfreaks.com/topic/260796-cannot-modify-header-information/#findComment-1336653 Share on other sites More sharing options...
runnerjp Posted April 12, 2012 Author Share Posted April 12, 2012 I fixed the error by removing the spaces! but thankyou for this information Also, session_unregister() was depreciated 10 years ago, throws a depreciated error message in php5.3, and has been completely removed in php5.4 that was just released. You would instead unset() the MemberArea $_SESSION variable. Quote Link to comment https://forums.phpfreaks.com/topic/260796-cannot-modify-header-information/#findComment-1336654 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.