|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-09-30 09:43 UTC] sander@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
When setting multiple cookies in a script, only the last cookie remains. I tested it by: setcookie("one", "1"); setcookie("two", "2"); setcookie("three", "3"); Then I fetched the script via telnet to see the headers, and only one header was set: Set-Cookie: three=3 I tracked it down to ext/standard/head.c, end of the php_setcookie-funkction. There, sapi_add_header gets executed. sapi_add_header is a macro to sapi_add_header_ex with the replace-bit SET! That means, every cookie gets overwritten by its predecessor. In fact, only the last cookie remains. I fixed it by exchanging the line return sapi_add_header(cookie, strlen(cookie), 0); with return sapi_add_header_ex(cookie, strlin(cookie), 0, 0 TSRMLS_CC); After compiling the patched PHP, setting multiple cookies succeedes. Is that a bug in PHP or was it written on purpose, that only one cookie can be set? I could have changed the macro in main/SAPI.h, but the macro is used in ext/zlib/zlib.c and ext/session/session.c and I didn't want to confuse them.