|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-12-22 17:21 UTC] tom916 at qq dot com
Description:
------------
When the browser client send 2 Cookie: in header,the php get first cookie name has a comma in the fist char。God know know the browser send 2 Cookie in header ?
Array
(
[,_a] => 1
)
Test script:
---------------
------------------show_cookie.php--------------
<?php
print_r($_COOKIE);
------------------send_cookie.php--------------
<?php
$fp = fsockopen("localhost", 50080, $errno, $errstr, 30); //my apache listen on 50080
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET /show_cookie.php HTTP/1.1\r\n";
$out .= "Host: localhost:50080\r\n";
$out .= "Cookie:\r\n";
$out .= "Cookie: a=1\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
php send_cookie.php
---------result-----------
HTTP/1.1 200 OK
Date: Sat, 22 Dec 2012 17:11:59 GMT
Server: Apache/2.2.17 (Unix) PHP/5.3.3
X-Powered-By: PHP/5.3.3
Content-Length: 25
Connection: close
Content-Type: text/html
Array
(
[,_a] => 1
)
Expected result:
----------------
Array
(
[a] => 1
)
Actual result:
--------------
Array
(
[,_a] => 1
)
Patchesbug63835.patch (last revision 2012-12-23 06:04 UTC by laruence@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 18:00:01 2025 UTC |
Now if the cookie name has a comma ,It becomes 2 cookie name <?php $fp = fsockopen("localhost", 50080, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $out = "GET /show_cookie.php HTTP/1.1\r\n"; $out .= "Host: localhost:50080\r\n"; // $out .= "Cookie:\r\n"; $out .= "Cookie: a=1; b=2; c,d=abc\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } ---------------------------- Array ( [a] => 1 [b] => 2 [c] => [d] => abc )