Now: Tutorial for Web and Software Design > PHP > QA > PHP Content
> PHPFAQ - I keep getting headers already sent whilst trying to use sessions [Bookmark it]
PHPFAQ - I keep getting headers already sent whilst trying to use sessions


Question :

I keep getting "headers already sent" whilst trying to use sessions

Answer :> "Warning: Cannot send session cookie - headers already sent by (output
> started at d:\wwwroot\b2b\cart.php3:9) in d:\wwwroot\b2b\cart.php3 on line
> 11
>
> What is it?? I think I am missing something in the php.ini file, but I
dont
> know what.
>
> Any ideas??
>
>

I replied to Agustin as follows, hopefully it's all correct....

cheers

Peter


Hi Agustin

Check through your code prior to the session_start(); command. You will
have already output some text to the browser, and since headers (and
cookies which are contained within headers) need to be sent before any
output, this error is happening.

Look for any print, printf, or echo commands. Also look for
whitespaces, tabs etc. before the session_start();

Bear in mind your include('file') statements, they might be causing the
problem, rather than the code in the file you're working on.

HTH

Cheers

Pete

[Bookmark][Print] [Close][To Top]
  • Prev Article-PHP:

  • Next Article-PHP:
  • Related Materias
    PHPFAQ - How google is you
    PHPFAQ - Are there any web
    PHPFAQ - How can I accept 
    PHPFAQ - How can I finance
    PHPFAQ - Where can I get P
    PHPFAQ - Where can I host 
    PHPFAQ - Where can I find 
    PHPFAQ - I am trying to cr
    PHPFAQ - Is there a librar
    PHPFAQ - How can I manage 
    Topics
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Graphic Design Tutorial
     

    Coreldraw Tutorial

      Illustrator Tutorial
      3D Graphics Articles
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial&Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial&Articles
     

    XML Style Tutorial

      AJAX Tutorial
      XML Mobile
    Flash Tutorial&Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial&Articles
     

    Linux Tutorial

      Symbian Tutorial
      MacOS Tutorial