ok here is the error in full:
Warning: Cannot modify header information - headers already sent by (output started at /getcookie.php:4) in /getcookie.php on line 46
I have been Searching for days on solutions that may fix this problem and people always lead back to the header, see the funny part is that im not touching the header, i think the problem maybe that im trying to use a second cookie and i am also using sessions, im using phpbb and i am making a second login for my main site so that they are integrated, the error always occurs when the script trys to set the cookie. here is the actual code, any help would be greatly appreciated.
if (($username == $user) && ($p == "3")) {
$check = "1";
echo "Full Access";
setcookie ("admin","admin1");
}
To help you all understand my coding $username is the name they entered into the login field and $user is the username set inside the database, $p is the permission level.
Warning: Cannot modify header information...
Moderator: General Moderators
The only time I've had this problem is when I'm echoing something before I change the headers. So, for example, if I have
I'll get that error.
What is being done on line 46? Is there output? One final thought is that session_start() needs to be the first thing done on any page using sessions. Anything before it will break. That may be your problem.
Code: Select all
echo "test";
header("Location: somewhere.else");What is being done on line 46? Is there output? One final thought is that session_start() needs to be the first thing done on any page using sessions. Anything before it will break. That may be your problem.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Thx for your help.
Yeah it was a series of things that was causeing the error, first off was the session thing at the top of the page ( i didnt have it) second was i was echoing a command before i was setting the cookie. Thanks for all your help.