Re: Help! Can't set cookie or redirect!!!
| From: | Chris Shiflett | Date: | Sun, 29 Sep 2002 01:16:24 +0000 |
| Subject: | Re: Help! Can't set cookie or redirect!!! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-118025@lists.php.net to get a copy of this message | ||
Phil,
You are sending output somewhere prior to the following line:
header("Location: " . $HTTP_POST_VARS["refURL"]);
Basically, as soon as you output anything, PHP has to assume you are finished manipulating headers.
Output can be anything from a space, newline, or HTML. It is not your setcookie() function but something that happens prior to that. Remember that everything not in PHP mode is considered output.
Chris
Phil Powell wrote:
I am getting the following errors attempting to set a cookie and redirect: Warning: Cannot add header information - headers already sent by (output started at /users/ppowell/web/my/process.php:5) in /users/ppowell/web/my/process.php on line 76 Warning: Cannot add header information - headers already sent by (output started at /users/ppowell/web/my/process.php:5) in /users/ppowell/web/my/process.php on line 77 Lines: setcookie("valLayout", $id, time()+3600*24*30*12*100, $SERVER_NAME); // WILL EXPIRE IN 100 YEARS.. UM YEAH header("Location: " . $HTTP_POST_VARS["refURL"]); The first time I ran this script it set the cookie just fine; subsequent runnings of this script produce this error. What am I doing wrong, anyone?