php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8382 re-sending http header due to session_start()
Submitted: 2000-12-22 16:38 UTC Modified: 2000-12-22 18:00 UTC
From: jmessner at neo dot rr dot com Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.2 OS: Mandrake 7.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jmessner at neo dot rr dot com
New email:
PHP Version: OS:

 

 [2000-12-22 16:38 UTC] jmessner at neo dot rr dot com
This related to bug #7877, which was said not to be a bug, and that you must session_start() before any html gets sent so that the cookie gets sent before the html header.  Otherwise, calling session_start() gives the error messages stated in #7877.

At least in 4.0.2, I have found that you cannot even have so much as one blank line in your php file before your <?php tag, or else the initial header gets sent and start_session() fails.  You MUST have <?php as the absolute very first bytes of your file.

This should either be fixed, or at least well documented.  The docs don't say anything about the importance of start_session() being called immediately, nor do they say anywhere that if you have any blank lines before your <?php tag that it will then be too late to start a session.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-22 18:00 UTC] sas@php.net
If you want to send any content before using functions which manipulate the HTTP header, I suggest enabling output buffering. This is not a bug and hence this report gets closed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 14:01:31 2025 UTC