error with sessions and headers being sent, yet nothing but headers have been sent

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lkrubner@geocities.com

    error with sessions and headers being sent, yet nothing but headers have been sent

    I'm getting this error:

    Warning: session_start() : Cannot send session cache limiter - headers
    already sent in
    /home/httpd/vhosts/publicdomainsof tware.org/httpdocs/pdsIncludes/McSessionInfo.p hp
    on line 34



    This is line 33 to line 36 of that class:


    function startSession() {
    session_start() ;
    session_registe r();
    }





    Why would this generate an error?

  • Gordon Burditt

    #2
    Re: error with sessions and headers being sent, yet nothing but headers have been sent

    >I'm getting this error:[color=blue]
    >
    >Warning: session_start() : Cannot send session cache limiter - headers
    >already sent in[/color]

    Don't send ANYTHING before you call session_start() .
    No blank lines (these are very often difficult to notice).
    No debug code.
    No DOCTYPE.
    No error or warning messages from functions that complain.
    (like access to uninitialized variables).
    No HTML.


    Gordon L. Burditt

    Comment

    • Andy Hassall

      #3
      Re: error with sessions and headers being sent, yet nothing but headers have been sent

      On 2 Jun 2005 13:01:15 -0700, lkrubner@geocit ies.com wrote:
      [color=blue]
      >I'm getting this error:
      >
      >Warning: session_start() : Cannot send session cache limiter - headers
      >already sent in
      >/home/httpd/vhosts/publicdomainsof tware.org/httpdocs/pdsIncludes/McSessionInfo.p hp
      >on line 34
      >
      >This is line 33 to line 36 of that class:
      >
      > function startSession() {
      > session_start() ;
      > session_registe r();
      > }
      >
      >Why would this generate an error?[/color]

      What version of PHP are you on? Typically that error message also includes the
      location that first produced the output, _as well as_ the line that failed
      because headers have already been sent.

      Don't know if the additional information is version specific...

      --
      Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
      <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

      Comment

      • chotiwallah

        #4
        Re: error with sessions and headers being sent, yet nothing but headers have been sent

        put an ob_start() in the 1st line, this will prevent the sending of any
        ouput

        ob_end_clean() just above the session call will discard the buffer and
        allow your session to start clean

        for debugging you could use ob_get_clean(), returns the sent output as
        a string to examine

        micha

        Comment

        Working...