#20923 [Opn]: Buffering Prevents setcookie()
| From: | viszneki at telerama dot com | Date: | Tue, 10 Dec 2002 17:21:49 +0000 |
| Subject: | #20923 [Opn]: Buffering Prevents setcookie() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-27281@lists.php.net to get a copy of this message | ||
ID: 20923
User updated by: viszneki@telerama.com
Reported By: viszneki@telerama.com
Status: Open
Bug Type: HTTP related
Operating System: Windows XP
PHP Version: 4.2.3
New Comment:
That previous script I wrote behaves strangely.
I erased my cookies, then loaded the page. As expected, no cookies were
sent from my web browser, and the script simply said "=1 =2 =3 =4" with
the BR tags between them.
I hit reload, and only 1 and 2 showed the appropriate cookies, Uno and
Dos. I hit reload again, and now Tres and Quatro show up.
I did this process 3 times to make sure it was consistent, and it
happens the same way every time.
Previous Comments:
------------------------------------------------------------------------
[2002-12-10 11:19:07] viszneki@telerama.com
I just wrote another script just to confirm the problem, and, well
instead I did the opposite. This script seems to have upset my previous
thoughts, so I'll keep trying to figure out what the problem is, it may
be my own fault.
<?php
setcookie( "one", "uno", time()+10000 );
setcookie( "two", "dos", time()+10000 );
echo $_COOKIE['one'], '=1<br>', $_COOKIE['two'],
'=2<br>',
setcookie( "three", "tres", time()+10000 );
setcookie( "four", "quatro", time()+10000 );
echo $_COOKIE['three'], '=3<br>', $_COOKIE['four'],
'=4<br>';
?>
------------------------------------------------------------------------
[2002-12-10 11:09:29] viszneki@telerama.com
I just went from PHP 4.1.2 to 4.2.3, and after some investigation,
found that setcookie would absolutely not set cookies. So I wrote a
test script to flip a cookie value each time you reloaded the script.
But it worked just fine. I investigated some more. Totally confused, I
wrote a script to flip a cookie again, but this time it didn't work.
It turned out that if I setcookie() after sending non-header data, that
the cookie never showed up. I remembered that previously I would get a
header error, and also remembered that in the PHP.INI that came with
the new php, they had enabled output buffering. Changing the buffering
settings seems to makes no difference.
My PHP Build was just one downloaded from the php.net downloads page,
nothing special about it.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20923&edit=1