Bug #69523 [Opn->Nab]: setcookie() uses second parameter as name (first param)
| From: | cmb@php.net | Date: | Fri, 24 Apr 2015 14:49:45 +0000 |
| Subject: | Bug #69523 [Opn->Nab]: setcookie() uses second parameter as name (first param) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192327@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69523&edit=1
ID: 69523
Updated by: cmb@php.net
Reported by: florian dot schmidt dot welzow at t-online dot de
Summary: setcookie() uses second parameter as name (first
param)
-Status: Open
+Status: Not a bug
Type: Bug
-Package: Output Control
+Package: *Web Server problem
Operating System: Ubuntu 14.04.2
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Consider the following statement:
setcookie('', 'value');
This constructs the following header field:
Set-Cookie: =value
This header field conforms to RFC 6265, section 4.1.1[1], because
cookie-name may be empty. So PHP allows what is permitted according
to the relevant RFC.
What's happening on the client side is not a PHP issue. The
behavior your are describing (name and value are swapped) happens
on Chrome 42.0.2311.90 m, but not on Firefox 37.0.2, for instance.
[1] <http://tools.ietf.org/html/rfc6265#section-4.1.1>
Previous Comments:
------------------------------------------------------------------------
[2015-04-24 10:55:49] florian dot schmidt dot welzow at t-online dot de
Description:
------------
If you use the script provided in "Test script" section, you''ll set a new
cookie with the name "value" and an empty value. That seems to be a false behavior, the
name of the cookie is required[1] and php should throw a fatal error, if an empty name is provided.
[1] http://php.net/manual/de/function.setcookie.php
Test script:
---------------
setcookie('', 'value', time()+10);
var_dump($_COOKIE);
Expected result:
----------------
Warning/Fatal error
Actual result:
--------------
A new cookie set with "value" as "name"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69523&edit=1