Jump to content

Cannot modify header information


runnerjp

Recommended Posts

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/";
?>

Link to comment
https://forums.phpfreaks.com/topic/260796-cannot-modify-header-information/
Share on other sites

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.

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.