php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47740 http_build_cookie() always returns false
Submitted: 2009-03-21 04:14 UTC Modified: 2009-05-06 20:57 UTC
From: jonathan dot aquino at gmail dot com Assigned: mike
Status: Not a bug Package: HTTP related
PHP Version: 5.2CVS-2009-03-21 (snap) OS: Unix
Private report: No CVE-ID:
 [2009-03-21 04:14 UTC] jonathan dot aquino at gmail dot com
Description:
------------
http_build_cookie returns false. PHP 5.2.6.

Reproduce code:
---------------
$cookie = http_parse_cookie('RMID=2dab5fc9296749c2f28ec0b7; expires=Saturday, 20-Mar-2010 01:34:06 GMT; path=/; domain=.nytimes.com'); 
var_dump(http_build_cookie($cookie)); 

Expected result:
----------------
RMID=2dab5fc9296749c2f28ec0b7

Actual result:
--------------
FALSE

Patches

ssss (last revision 2011-08-11 12:19 UTC) by ddddd at hotmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-21 04:31 UTC] kalle@php.net
The prototype for http_build_cookie() says that it accepts an array only and the description below it says an array/object. The following:
C:\php\src\Release_TS>php -r "$c = http_parse_cookie('RMID=2dab5fc9296749c2f28ec0b7; expires=Saturday, 20-Mar-2010 01:34:06 GMT; path=/;domain=.nytimes.com'); var_dump(http_build_cookie($c));"

gives:
Warning: http_build_cookie() expects parameter 1 to be array, object given in Command line code on line 1
bool(false)

however casting it to an array before passing it to http_build_cookie, like:
http_build_cookie((array) $c);


makes it work, assigned to Mike so he can clarrify its an error with pecl/http or a documentation issue.
 [2009-05-06 20:57 UTC] jani@php.net
PECL bugs are supposed to be reported elsewhere, not in PHP core bugs.
http://pecl.php.net/bugs/ is good place to begin with..
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 21:01:55 2014 UTC