|
-
Jul 30th, 2003, 01:08 AM
#1
Thread Starter
New Member
set cookie help
hey everyone, i am looking for some help with the set cookies command in PHP. I searched the forum to see what came up and found some help on the error i was getitng but nothing that pertained to my certain sittuation that i could see. I am getting this error:
Warning Cannot add header information - headers already sent by...
Now from what i read on this forum this was caused by either a space before or after the set cookie command or output (print , echo etc) before the SetCookie function is executed, but my program has neither of these problems.. here is some of the code (the 3 or 4 lines where the error is occuring):
PHP Code:
if($pword==$pass) {
$info="$uname;$pword";
setcookie("User",$info, time()+86400);
ShowForum();
}
Could it be because i am calling the ShowForum function after, i elliminated the $info variable and the ShowForum call to see if that was the cause and i got nothing.. ne suggestions?
-
Jul 30th, 2003, 11:16 AM
#2
Frenzied Member
what ever is above that is messing it up. what is the exact error, it says what line it is happening on. and it is not just spaces, but anything that is echoed out to the browser before that cookie is set will cause the error as well.
-
Aug 24th, 2003, 04:50 PM
#3
New Member
You're getting this error because output_buffering is set to off, which means that if you call set_cookie or use any session variables after the output of the page has been started, they don't get set. There's two workarounds for this. Either turn on output_buffering in the php.ini file, then restart apache, or make sure that your code block that sets the cookie appears before ANY output you make, even just an echo statement.
-
Aug 25th, 2003, 12:18 PM
#4
Stuck in the 80s
Is it just me or is the most commonly asked question on these boards?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|