Re: setcookie()
| From: | Miguel Cruz | Date: | Sun, 12 May 2002 05:04:44 +0000 |
| Subject: | Re: setcookie() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-97200@lists.php.net to get a copy of this message | ||
On Sat, 11 May 2002, jtjohnston wrote:
> This is a bug "Feature/Change Request" I made to:
> http://bugs.php.net/bug.php?id=17158
>
> setcookie() states "cookies must be sent before any other headers
> are sent (this is a restriction of cookies, not PHP).
>
> I argue this is a restriction of PHP, not cookies.
It's a benefit of PHP. Unlike certain other languages, PHP gives you finer
control over how things are sent. The side-effect of this is that you are
able to attempt things that don't make sense and can't work.
If you want to use setcookie() anywhere within your PHP program, then
just call ob_start() at the top of your code and go to town.
miguel