php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #2937 session_start() fails when used after require() or include()
Submitted: 1999-12-08 14:06 UTC Modified: 1999-12-10 06:11 UTC
From: marvin at minotaur dot com Assigned:
Status: Closed Package: Session related
PHP Version: 3.0.12 OS: linux
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: marvin at minotaur dot com
New email:
PHP Version: OS:

 

 [1999-12-08 14:06 UTC] marvin at minotaur dot com
I am using PHP 4.0 beta 2


Basically if I do

<?
   session_start();

   require 'htmlstuff.php'

   blah blah blah
?>

the code works...

but if I do

<?

  require 'htmlstuff.php'

  session_start();

  blah blah blah
?>

I get an error reading like:

Warning: Cannot add header information - headers already sent in /home/marvin/sla/index.php on line 5

If I use include instead of require, same error message.  This also means I can not use session_start inside of a function in a header file.

Contact me for clarifications/more info.

Marvin

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-12-10 06:11 UTC] sas at cvs dot php dot net
You have some kind of white-space in your included files which triggers sending the HTTP headers. Either enable output buffering or remove the white-space in the included files.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC