Re: Fw: [PHP] Re: headers and cookies
what I found out in the meantime is that you CAN use cookies and headers, just like you said, but my particular problem arose because a notice was issued for an undefined variable; I didn't check correctly for it's existence. so any output, and also output like notices, warnings and errors, just anything you might get in a development situation, outputs headers and the consecutive calls to header() or setcookie() will fail. for clarity, this was the output: notice; undefined index: bla in file.php on line 162 #wrong check in if condition warning: cannot add header infromation - headers already sent by (output started at file.php) in file.php on line 164#wetcookie call, but notice has already been sent out, so this will fail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fw: [PHP] Re: headers and cookies
There is no such "restriction of cookies." I think what the manual meant to say was that cookies must be sent prior to any output, which is the same restriction any other header has that you wish to set with the header() function, for example. I have forwarded this along to the documentation team. Thanks for pointing it out. Chris Kevin Stone wrote: http://www.php.net/manual/en/function.setcookie.php And I quote, "setcookie() defines a cookie to be sent along with the rest of the header information. Cookies must be sent before any other headers are sent (this is a restriction of cookies, not PHP)."; If you absolutely must set cookies after you set other headers then use Output Buffering. http://www.php.net/manual/en/function.ob-start.php -Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP] Re: headers and cookies
http://www.php.net/manual/en/function.setcookie.php And I quote, "setcookie() defines a cookie to be sent along with the rest of the header information. Cookies must be sent before any other headers are sent (this is a restriction of cookies, not PHP)."; If you absolutely must set cookies after you set other headers then use Output Buffering. http://www.php.net/manual/en/function.ob-start.php -Kevin - Original Message - From: "rolf vreijdenberger" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, October 29, 2002 1:59 PM Subject: [PHP] Re: headers and cookies > > but are you really sure that you cannot use setcookie() and header() at the > same time?? > I cannot find it anywhere, either in the manuals or in tutorials or in the > output control functions! > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: headers and cookies
but are you really sure that you cannot use setcookie() and header() at the same time?? I cannot find it anywhere, either in the manuals or in tutorials or in the output control functions! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php