php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73344 header() removes previously defined headers when replace flag is false
Submitted: 2016-10-19 04:58 UTC Modified: 2016-10-19 05:27 UTC
From: yohgaki@php.net Assigned: yohgaki (profile)
Status: Not a bug Package: Unknown/Other Function
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2016-10-19 04:58 UTC] yohgaki@php.net
Description:
------------
header() removes previously defined headers when replace flag is false.

Test script:
---------------
<?php
ob_start();

ini_set('session.use_cookies', 1);
ini_set('session.save_handler', 'files');

session_name('BUG');
session_start();

// Bug0
session_regenerate_id(true);

// Bug2
header(sprintf('Set-Cookie: BUG=BUG2; expires=Sat, 03-Sep-2020 05:38:43 GMT; path=/;', false));


Expected result:
----------------
$ ./sapi/cgi/php-cgi s.php
X-Powered-By: PHP/5.6.28-dev
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: BUG=45df8aabbae8b88139fefdc46c2de696; path=/
Set-Cookie: BUG=BUG2; expires=Sat, 03-Sep-2020 05:38:43 GMT; path=/;
Content-type: text/html; charset=UTF-8


Actual result:
--------------
$ ./sapi/cgi/php-cgi s.php
X-Powered-By: PHP/5.6.28-dev
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: BUG=BUG2; expires=Sat, 03-Sep-2020 05:38:43 GMT; path=/;
Content-type: text/html; charset=UTF-8


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-19 04:59 UTC] yohgaki@php.net
-Assigned To: +Assigned To: yohgaki
 [2016-10-19 05:27 UTC] yohgaki@php.net
-Status: Assigned +Status: Not a bug
 [2016-10-19 05:27 UTC] yohgaki@php.net
There was bug in script. Remove flag works fine.
I should have removed needless sprintf().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 16:01:28 2024 UTC