From: [EMAIL PROTECTED] Operating system: Linux 2.2.17 (Debian potato) PHP version: 4.2.2 PHP Bug Type: HTTP related Bug description: Only last cookie of multiple setcookies is set.
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. -- Edit bug report at http://bugs.php.net/?id=19673&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=19673&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=19673&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=19673&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=19673&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=19673&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=19673&r=support Expected behavior: http://bugs.php.net/fix.php?id=19673&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=19673&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=19673&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=19673&r=globals