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 this is not your bug, you can add a comment by following this link.
If this is your bug, but 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

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-2022 The PHP Group
All rights reserved.
Last updated: Sun Sep 25 16:05:53 2022 UTC