|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2001-05-31 12:58 UTC] sniper@php.net
  [2003-04-14 05:21 UTC] sumairi at hotmail dot com
  [2004-05-12 08:49 UTC] ckathir_nkl at yahoo dot co dot in
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 15:00:01 2025 UTC | 
To debug my latest PHPLib commits I needed some output before session_start() without sending any headers to the browser. Well, I thought of using error_log() that should not output anything but write to my logfile. I changed my php.ini to: display_errors = Off log_errors = On error_log = [mypath]/logs/ Now I hoped that I'd be allowed to use error_log() before session_start(), here's a simple example: <?php error_log("I don't like that!"); session_start(); session_register("counter"); print ++$counter; error_log("counter = $counter"); error_log(" ") ?> But PHP bailed at me in the error_log: I don't like that! PHP Warning: Cannot send session cookie - headers already sent in [mypath]/bug.php3 on line 4 [mypath]/bug.php3(4) : Warning - Cannot s end session cookie - headers already sent PHP Warning: Cannot send session cache limiter - headers already sent in [mypath]/bug.php3 on line 4 [mypath]/bug.php3(4) : Warning - Cannot s end session cache limiter - headers already sent counter = 1 Hmm, did I forget a auto_prepend file, could I be doing any output before session_start()? Let's check the results of a command line telnet request. HTTP/1.1 200 OK Date: Thu, 31 May 2001 13:38:27 GMT Server: Apache/1.3.14 (Unix) PHP/4.0.5-dev mod_ssl/2.7.1 OpenSSL/0.9.5a X-Powered-By: PHP/4.0.5 Connection: close Content-Type: text/html 1Connection closed by foreign host. No, I did not output anything before session_start(). Then I uncommented the first error_log() call and everything was just fine. The error log showed: counter = 1 counter = 2 ... The problem is the same with 4.0.4pl1 (as one could expect).