Please help!"session start cannot modify header information&q

Happens in my Flash and Drupal site after using Adobe Contribute

Page 1 of 1

1 Replies - 2153 Views - Last Post: 01 January 2009 - 06:48 PM

#1 xxsassxx31   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 22-October 08

Please help!"session start cannot modify header information&q

Post icon  Posted 01 January 2009 - 02:58 PM

I had an error in which I had someone do a fix of my index.php file for my website and everything was solved and perfect! I always used Adobe Contribute CS4 to add the page title and header information (keywords & description) but this was the first time since this guy had helped me fix my problem in which I had modified the wrong file and when I used Contribute to edit the page title & header, my website instantly gave the following error message on the top of the flash and even my drupal (html portion) of the site:

"Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/s/h/a/shawn31/html/index.php:3) in /home/content/s/h/a/shawn31/html/includes/ on line 899

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/s/h/a/shawn31/html/index.php:3) in /home/content/s/h/a/shawn31/html/includes/ on line 899

Warning: Cannot modify header information - headers already sent by (output started at /home/content/s/h/a/shawn31/html/index.php:3) in /home/content/s/h/a/shawn31/html/includes/ on line 531

Warning: Cannot modify header information - headers already sent by (output started at /home/content/s/h/a/shawn31/html/index.php:3) in /home/content/s/h/a/shawn31/html/includes/ on line 532

Warning: Cannot modify header information - headers already sent by (output started at /home/content/s/h/a/shawn31/html/index.php:3) in /home/content/s/h/a/shawn31/html/includes/ on line 533

Warning: Cannot modify header information - headers already sent by (output started at /home/content/s/h/a/shawn31/html/index.php:3) in /home/content/s/h/a/shawn31/html/includes/ on line 534"

I went back to my Adobe Contribute CS4 and deleted the keywords and description I had entered and attempted to get rid of the title but it wouldn't and won't let me since I had already inputted it via Contribute. Also, I assume what it is, is that I already had the title in on my index.php.

I went to the following lines as stated in and I got the following:

Line 899: "session_start();"

Lines 531-534 (I posted lines 530-535 because it showed some drupal stuff which may or may not be applicable):
530: function drupal_page_header() {
531: header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
532: header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
533: header("Cache-Control: store, no-cache, must-revalidate");
534: header("Cache-Control: post-check=0, pre-check=0", FALSE);
535: }

This is what I see at the beginning of my index.php file:

<meta name="keywords" content="">

<meta name="description" content="">

<title>Alliance Direct Financial Source offers mortgage loan modification finance refinance short sale foreclosure bailout</title><?php

// $Id: index.php,v 1.91 2006/12/12 09:32:18 unconed Exp $

I don't want to dive into this alone as I don't want to mess anything up. The pages are tied to both my flash page and any part of my non-flash page such as . Can anyone please help me with this today since today is New Years and a non-workday? Thanks again for all your help and a Happy New Years to all!

Is This A Good Question/Topic? 0
  • +

Replies To: Please help!"session start cannot modify header information&q

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5227
  • View blog
  • Posts: 14,010
  • Joined: 18-April 07

Re: Please help!"session start cannot modify header information&q

Posted 01 January 2009 - 06:48 PM

Ok lets cover what the error means and then talk about why it is happening to you. Whenever the server sends out content to be shown to the user it must first send out header lines telling basic information including the content type, size, when it was last modified, etc. This is information for the browser to let it know how to handle the page and what the page has on it.

These lines must be first before the content and once they have been sent out, you can't write or try to send out additional headers later.

Lets take an example...

If I was to write the following code I would get the headers already sent error...

echo "test";
header("location: index.php");

Here I am trying to use a header function to tell the browser that it will need to be redirected to a file called index.php. But there is one problem, I used echo to output some text. So when PHP ran across the echo it flushed out the headers first, then for the body of the page it put "test".

So when I try to use header() after outputing the headers (it already sent) and the content it is going to say error that the headers have already been sent because I forced the header lines to be sent to the user because I was writing to the output stream to the user. This is for ANY OUTPUT. So I had printed something in normal HTML (even a simple space character) it will cause the headers to be sent and then cause this error when trying to use the header() function.

If I had gone....

header("location: index.php");
echo "test";

It would have been no problem because I told the browser to redirect and it would have added that onto the header lines and sent that prior to the echo being executed. The browser would redirect and no error.

session_start() is a function, which uses a session cookie, must be sent out with these headers at the start. Ideally you will want your session_start() at the beginning of a file, but you can have it anywhere in your PHP code as long as the page has NOT outputted any code yet.

So if you have something in the pages printing out to the user through an echo or a print or even regular HTML and then try to call drupal_page_header() you are going to get the error.

To start you may want to look at and see if there is any way that some output is being sent prior to drupal_page_header() being called. And I do mean ANYTHING. A space, an echo, a print etc. Then make sure that all your calls to header() is done first before the output is done. Since your header calls are in a function in lines 530-535 are before session start see if there is any lines being printed prior to where drupal_page_header is being CALLED and where session_start() is being called on line 899.

Hopefully that makes sense to you. If you continue to have trouble seeing the problem, try showing us lines 530 to 899 only. We will then let you know if we need to see more. But please do try and find the lines yourself because if you show us and the line is sticking out obvious as day on line 536 or something we will not be too happy.

Thanks. :)
Was This Post Helpful? 1

Page 1 of 1