Warning: session_start(): Cannot send session cookie - headers already sent by

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob

    Warning: session_start(): Cannot send session cookie - headers already sent by

    Seem to have a problem ending a session. I get the following message.


    Warning: session_start() : Cannot send session cookie - headers already
    sent by (output started at
    C:\xitami\xitam i-24\app\webpages \logout.php:9) in
    C:\xitami\xitam i-24\app\webpages \logout.php on line 10

    Warning: session_start() : Cannot send session cache limiter - headers
    already sent (output started at
    C:\xitami\xitam i-24\app\webpages \logout.php:9) in
    C:\xitami\xitam i-24\app\webpages \logout.php on line 10

    You have been logged off, you must re-login to use the system.
    Log In

    The code is as follows.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>Logged Out</title>
    </head>

    <body>
    <?php
    session_start() ;
    session_unset() ;
    session_destroy ();

    //unset($HTTP_SES SION_VARS['valid_user']);
    //unset($HTTP_SES SION_VARS['privlevel']);
    //session_destroy ();

    echo '<h3>You have been logged off, you must re-login to use the
    system.</h3>';
    echo '<a href="log_in.ph p">Log In</a><br />';
    ?>

    </body>
    </html>


    I am using Homesite4.5 and saving the file as "pc" format. The
    webserver is Xitami.

    Help would be appreciated.
  • Gordon Burditt

    #2
    Re: Warning: session_start() : Cannot send session cookie - headers already sent by

    >Seem to have a problem ending a session. I get the following message.[color=blue]
    >
    >Warning: session_start() : Cannot send session cookie - headers already
    >sent by (output started at[/color]

    You may not output ANYTHING before calling session_start() , (or
    other functions that need to send headers, like cookie setting).
    Nada. Zip. Nothing. Put your HTML, DOCTYPE, blank lines, single
    spaces, etc. *after* calling session_start() .

    Gordon L. Burditt
    [color=blue]
    >C:\xitami\xita mi-24\app\webpages \logout.php:9) in
    >C:\xitami\xita mi-24\app\webpages \logout.php on line 10
    >
    >Warning: session_start() : Cannot send session cache limiter - headers
    >already sent (output started at
    >C:\xitami\xita mi-24\app\webpages \logout.php:9) in
    >C:\xitami\xita mi-24\app\webpages \logout.php on line 10
    >
    >You have been logged off, you must re-login to use the system.
    >Log In
    >
    >The code is as follows.
    >
    ><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    >
    ><html>
    ><head>
    > <title>Logged Out</title>
    ></head>
    >
    ><body>
    ><?php
    >session_start( );
    >session_unset( );
    >session_destro y();
    >
    >//unset($HTTP_SES SION_VARS['valid_user']);
    >//unset($HTTP_SES SION_VARS['privlevel']);
    >//session_destroy ();
    >
    >echo '<h3>You have been logged off, you must re-login to use the
    >system.</h3>';
    >echo '<a href="log_in.ph p">Log In</a><br />';
    >?>
    >
    ></body>
    ></html>
    >
    >
    >I am using Homesite4.5 and saving the file as "pc" format. The
    >webserver is Xitami.
    >
    >Help would be appreciated.[/color]


    Comment

    • nice.guy.nige

      #3
      Re: Warning: session_start() : Cannot send session cookie - headers already sent by

      While the city slept, Bob (clarke@quality think.com) feverishly typed...
      [color=blue]
      > Seem to have a problem ending a session. I get the following message.
      >
      > Warning: session_start() : Cannot send session cookie - headers already[/color]
      [etc]

      You cannot have any output before the session (including normal HTML
      output). Try re-organising as follows;

      <?php
      session_start() ;
      session_unset() ;
      session_destroy ();

      //unset($HTTP_SES SION_VARS['valid_user']);
      //unset($HTTP_SES SION_VARS['privlevel']);
      //session_destroy ();
      ?>

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

      <html>
      <head>
      <title>Logged Out</title>
      </head>

      <body>
      <h3>You have been logged off, you must re-login to use the system.</h3>';
      <p><a href="log_in.ph p">Log In</a></p>
      </body>
      </html>

      .... A couple of non-php points. It is probably time for you to consider
      coding the HTML 4.01 Strict doctype. Why have you used H3 to mark up the
      "You have been logged off..." text? Where are the first and second level
      headings that should precede it?

      Hope that helps,
      Nige

      --
      Nigel Moss
      This is the personal website of Nigel Moss - Web and software developer, musician, photographer. It is home to my CV, portfolio, general info and more.

      Mail address not valid. nigel@DOG.nigen et.org.uk, take the DOG. out!
      In the land of the blind, the one-eyed man is very, very busy!


      Comment

      • Bob

        #4
        Re: Warning: session_start() : Cannot send session cookie - headers already sent by

        Thanks to both of you for the help.

        Comment

        • nice.guy.nige

          #5
          Re: Warning: session_start() : Cannot send session cookie - headers already sent by

          While the city slept, Bob (clarke@quality think.com) feverishly typed...
          [color=blue]
          > Thanks to both of you for the help.[/color]

          Your welcome. :-)

          Cheers,
          Nige

          --
          Nigel Moss
          This is the personal website of Nigel Moss - Web and software developer, musician, photographer. It is home to my CV, portfolio, general info and more.

          Mail address not valid. nigel@DOG.nigen et.org.uk, take the DOG. out!
          In the land of the blind, the one-eyed man is very, very busy!


          Comment

          Working...