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
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:
MUST BE VALID
Solve the problem:
36 - 32 = ?
Subscribe to this entry?

 
 [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 26 12:01:30 2024 UTC