|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-04-15 17:19 UTC] svein dot olav at bjerkeset dot com
With Apache 2.0.35 and PHP 4.2.0RC4, only the last cookie
seems to get set.
Here is the PHP source I used for testing:
<?php
setcookie ('first_name', 'Svein', 0, '/');
setcookie ('last_name', 'Olav', 0, '/');
echo "<html><head></head><body>" .
"<h1>Cookie test page</h1>\n";
while (list ($var,$val) = each ($HTTP_COOKIE_VARS)) {
echo "Set-Cookie: $var=$val <br>\n";
}
echo "</body></html>";
?>
This script can be tested via the following URL:
https://bjerkeset.dns2go.com/php/cookie.php
PHP was configured like this:
./configure \
--prefix=/opt/php \
--with-mysql=/opt/mysql \
--with-config-file-path=/etc/opt/apache2 \
--enable-track-vars \
--enable-force-cgi-redirect \
--with-gettext \
--with-apxs2=/opt/apache2/bin/apxs
Svein Olav Bjerkeset
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 15:00:01 2025 UTC |
Now I know what "don't use this on a production server" means. :) Strangely, this bug also seems to affect header(). As a result of this bug, we replaced setcookie() with our own routine to write out cookies via header(). However, still, only one cookie (the last one) is being printed in the HTTP response headers (when I sniff the packets being sent). It's very strange... Here's the code we used to replace setcookie(). function send_htCookie() { $vars=array('varname','varval','expire','path','domain','secure'); for ($i=0;$i<func_num_args();$i++) { ${$vars[$i]}=func_get_arg($i); } if (!$varname) { return false; } $COOKIE = "Set-Cookie: $varname=$varval"; if (isset($expire)) { $COOKIE .= "; EXPIRES=$expire";} if (isset($domain)) { $COOKIE .= "; DOMAIN=$domain"; } if (isset($path)) { $COOKIE .= "; PATH=$path"; } if (isset($secure) && $secure>0) { $COOKIE .= "; SECURE"; } header($COOKIE); return true; } Can anyone confirm that this, too, doesn't work for them? I'll do more testing in the meantime...