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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Apr 19 11:01:28 2024 UTC