|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2968 white space in document before setcookie() is called ruins chance to setcookie
Submitted: 1999-12-13 14:19 UTC Modified: 1999-12-13 14:43 UTC
From: sladd at mail dot rit dot edu Assigned:
Status: Closed Package: Parser error
PHP Version: 3.0.12 OS: Linux 2.2.13
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
46 - 34 = ?
Subscribe to this entry?

 [1999-12-13 14:19 UTC] sladd at mail dot rit dot edu
I don't think this is the way it is supposed to be.

If there is white space before a setcookie() call, even if no text is sent, setcookie fails because it was thinking that text has been sent.

More exactly, if we have this (the dashes indicate begining of file)

<?php include(""); ?>

<?php setcookie("test", "test", time()+60); ?>

will FAIL, even though inside my I have no text being printed out.  The following DOES work.

<?php include(""); ?>
<?php setcookie("test", "test", time()+60); ?>

Notice how there is no space after the include.  The whitespace outside of the <?php ?> tags seems to matter.  This is not clearly defined in the documentation, and I believe it's a bug.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1999-12-13 14:43 UTC] joey at cvs dot php dot net
This /IS/ the way it is supposed to be. Please see:

In short, /ANY/ whitespace is considered "text to be sent".

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Mar 02 01:01:28 2024 UTC