|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #788 SetCookie will not work with whitespace leading the <SCRIPT language="php"> tag
Submitted: 1998-09-25 14:58 UTC Modified: 1998-09-25 15:09 UTC
From: mavpion at usa dot net Assigned:
Status: Closed Package: Performance problem
PHP Version: 3.0.4 OS: Linux
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:
16 - 7 = ?
Subscribe to this entry?

 [1998-09-25 14:58 UTC] mavpion at usa dot net
this script:
        <SCRIPT language="php">

Produces the error:
Oops, php3_SetCookie called after header has been sent 

whereas this script: 
<SCRIPT language="php">


Apparently the leading whitespace causes a header to be sent, making the cookie not work. Can you change this behavior? I am in the habit of right justifying the <script> tag, but if I want to use cookies, I must left justify it.


--Eric Guenterberg


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1998-09-25 15:09 UTC] zeev
Anything outside PHP code blocks is considered as raw HTML,
and is sent as-is, untouched by the language engine.  PHP
makes no distinction between whitespace and text, and that's
why your tab, or series of spaces, is considered an HTML
block which triggers the sending of the HTTP header.  This
behavior will not change in PHP 3.0.

In PHP 3.1, there'll be an optional switch to buffer all
output, and only send the HTTP header after the entire
file is parsed, so you'd be able to add in header information,
such as HTTP cookies, even after you output HTML.  Version
3.1 is still way off though.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Feb 27 06:01:26 2020 UTC