php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51116 header replace Set-Cookie as similar header
Submitted: 2010-02-22 17:14 UTC Modified: 2010-11-25 13:29 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: sailormax at inbox dot lv Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.12 OS: any
Private report: No CVE-ID: None
 [2010-02-22 17:14 UTC] sailormax at inbox dot lv
Description:
------------
function header() has second parameter = replace;
it turned on by default;
in result it replace all previous "Set-cookie:", including Set-cookie of session. Why it do not look at cookie name and domain? By standard header can contain several Set-cookie...

Yes, I can turn off replace, but for what this parameter in result? I think for remove duplicates in header. For remove duplicates like few "Content-type:", "Date:", "Expires:",... and for remove duplicates in few similar by _name, domain and path_ "Set-cookie:".

Reproduce code:
---------------
session_start();
header("Set-cookie: lang.name=en;expires=Wed, 01 Jan 2020 16:59:02 GMT;path=/;");

Expected result:
----------------
in header:
~~~~~~~~~~~~~
Set-Cookie: sessid=efd66810c22e02211ad598d93aff7d211e7b17b7; expires=Thu, 25 Feb 2010 16:59:02 GMT; path=/
Set-cookie: lang.name=en;expires=Wed, 01 Jan 2020 16:59:02 GMT;path=/;
~~~~~~~~~~~~~

all not duplicated cookies

Actual result:
--------------
in header:
~~~~~~~~~~~~~
Set-cookie: lang.name=en;expires=Wed, 01 Jan 2020 16:59:02 GMT;path=/;
~~~~~~~~~~~~~

only last cookie...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-24 14:03 UTC] jani@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2010-11-24 14:03 UTC] jani@php.net
If you don't want to replace, pass the 2nd parameter like this:

header("Set-cookie: lang.name=en;expires=Wed, 01 Jan 2020 16:59:02 GMT;path=/;",false);

The feature exists, so use it,.
 [2010-11-25 13:29 UTC] sailormax at inbox dot lv
I meant: Why "Set-cookie: lang.name" replace "Set-Cookie: sessid"?
Logically "Set-cookie: lang.name" should replace other "Set-cookie: lang.name", but not "Set-Cookie: sessid". Am I wrong?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 10:01:32 2025 UTC