php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55850 header() / setcookie() / session_start() give bogus warning
Submitted: 2011-10-04 23:38 UTC Modified: 2015-06-24 18:44 UTC
Votes:18
Avg. Score:2.1 ± 1.3
Reproduced:4 of 5 (80.0%)
Same Version:0 (0.0%)
Same OS:3 (75.0%)
From: tklingeberg at lastflood dot net Assigned:
Status: Verified Package: CGI/CLI related
PHP Version: 5.6.10 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tklingeberg at lastflood dot net
New email:
PHP Version: OS:

 

 [2011-10-04 23:38 UTC] tklingeberg at lastflood dot net
Description:
------------
SAPIs that do not support HTTP header(s), give warnings that output has been already sent like

"Warning: Cannot modify header information - headers already sent by..."

even those APIs do *not* support headers.

There is no use to warn about something that can never happen; There is nothing to modify; There are no headers that already have been sent.

It might make more sense to warn that this function is useless w/o HTTP response headers being available.

Compare with headers_sent(), it does differ between SAPIs.

Would be nice to have this a bit more streamlined.

Additionally header() could return FALSE if it failed like setcookie().

Test script:
---------------
In CLI:

<?php
echo "output";
session_start();
setcookie("TestCookie", 'value');
header('X-TestHeader: value');
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-24 18:44 UTC] cmb@php.net
-Status: Open +Status: Verified -Operating System: Linux +Operating System: * -PHP Version: 5.3.8 +PHP Version: 5.6.10
 [2015-06-24 18:44 UTC] cmb@php.net
Confirmed: <http://3v4l.org/CYsUm>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC