how do I fix this " Warning: session_start(): Cannot send session cache limiter"

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

    #16
    Re: how do I fix this " Warning: session_start() : Cannot send session cache limiter"


    Gordon Burditt wrote:[color=blue][color=green][color=darkred]
    > >> >>> session_start() ;
    > >> >>> session_registe r();
    > >> >>
    > >> >>You probably have a blank space or an empty line somewhere between the
    > >> >>beginning of a file and the first "<?"... Find it and delete it.[/color][/color]
    >
    > Unfortunately, white space and other body output isn't the only
    > thing that causes headers to be sent. Sending headers (e.g.
    > session_start() ) also causes headers to be sent. If you're going
    > to setcookie(), setcookie() before session_start() and before any
    > output.
    >
    > Also, don't call session_start() before session_start() . Limit:
    > one call per PHP hit.
    >
    > session_registe r() should only be used if register_global s is on,
    > which it shouldn't be, so don't use it. Use $_SESSION.
    >
    >[color=green]
    > >But as I said earlier in the thread, PHP is giving me bum messages that
    > >offer no illumination.[/color]
    >
    > They are telling you where the problem is. White space is a common,
    > and difficult to find, but not the only cause of headers being sent.[/color]

    I think you are right, they are telling me where the problem is. I now
    suspect the error was being triggered when this class method (which
    sends a charset header) was called:


    function command() {
    // 09-02-04 - we want the server to send a header explaining that the
    charset is
    // UTF-8 (which the software is now going to standardize around, I
    just changed
    // the functions standardInput() and standardOutput( ) to cast all
    input to UTF-8).
    // How can Apache know the right charset when all the text is stored
    in a MySql
    // database? It seems likely to me that we need to take responsiblity
    for ensuring
    // that the right header is sent. This function now gets called at
    the top of
    // both configAdminEven ts.php and configPublicEve nts.php

    $this->core->notes("We are at the beginning of command() in
    CommandSendUtf8 Header.");

    if (function_exist s("headers_sent ")) {
    $sent = headers_sent();
    if (!$sent) header("Content-type:text/html;charset=UT F-8");
    }
    $this->core->notes("We are at the end of command() in
    CommandSendUtf8 Header.");
    ob_end_flush();
    }

    Comment

    • Gordon Burditt

      #17
      Re: how do I fix this &quot; Warning: session_start() : Cannot send session cache limiter&quot;

      >> >> >>> session_start() ;[color=blue][color=green][color=darkred]
      >> >> >>> session_registe r();
      >> >> >>
      >> >> >>You probably have a blank space or an empty line somewhere between the
      >> >> >>beginning of a file and the first "<?"... Find it and delete it.[/color]
      >>
      >> Unfortunately, white space and other body output isn't the only
      >> thing that causes headers to be sent. Sending headers (e.g.
      >> session_start() ) also causes headers to be sent. If you're going
      >> to setcookie(), setcookie() before session_start() and before any
      >> output.
      >>
      >> Also, don't call session_start() before session_start() . Limit:
      >> one call per PHP hit.[/color]
      >
      >Thank you. Your advice is some of the most helpful that I've gotten.
      >But when I use my text editor to run a global search on all of my code,
      >I only find one call to session_start() .[/color]

      You can't do that with a text editor. You might call session_start()
      once from shoot_self_in_f oot() and call shoot_self_in_f oot() from
      several places and looping over each toe. Or you might include the
      code multiple times. Execution counts. Number of mentions in the
      source code doesn't. Order of execution counts. Order of mention
      in the source code doesn't. Things get even messier if the function
      calling session_start() is called from the constructor of a class.

      I'm not real convinced that include_once() is capable of distinguishing
      all possible names for the same file, and guaranteeing that it
      will be included only once:
      foo.php
      ./foo.php
      ././././foo.php
      ../dir/foo.php
      bar/../foo.php
      and it gets even worse with symlinks or hard links floating around.
      The manual page for include_once mentions some of this problem with
      respect to case-insensitive filesystems.


      One of your messages seemed to be session_start() complaining about
      headers already having been sent in a line you said contained
      session_start() . This is why I think you are calling session_start()
      more than once.

      [color=blue][color=green]
      >> session_registe r() should only be used if register_global s is on,
      >> which it shouldn't be, so don't use it. Use $_SESSION.[/color]
      >
      >I've deleted the call to session_registe r(). I hope this helps.[/color]

      This isn't likely relevant to your current problem, though.[color=blue]
      >[/color]
      [color=blue][color=green][color=darkred]
      >> >over and over again:
      >> >
      >> >
      >> >[18-Jun-2006 07:56:19] PHP Warning: Cannot modify header information -
      >> >headers already sent in[/color]
      >>
      >>/home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/CommandSetMachi neIdOnVisitorsM achine.php[color=darkred]
      >> >on line 26[/color]
      >>
      >> setcookie() goes before session_start() .[/color]
      >
      >Oh! That is very good to know. Can I ask where you found that
      >information? This page:
      >
      >http://us3.php.net/session_start
      >
      >says "If a user uses ob_gzhandler or like with ob_start(), the order of
      >output handler is important for proper output. For example, user must
      >register ob_gzhandler before session start."
      >
      >but from that it's not transparent to me that cookies must be called
      >before session_start() . Where is this stated as a general principle?[/color]

      Read the page for setcookie(). You have to call it before HTTP
      headers are sent. This is a protocol limitation you're stuck with.
      (And some of the details of this are obscured by output buffering).
      I don't think the documentation is particularly clear on this, and
      there are bits and pieces of details scattered all over.

      Some things modify HTTP headers, and should only be called BEFORE headers
      have been output:

      setcookie() header() session_start()
      session_cache_l imiter() various session_*() functions
      setrawcookie()
      This list is by no means complete.

      Some things force HTTP headers to be output if output buffering is not
      in use:
      session_start() Any text output
      <html> <!DOCTYPE
      Any white space Anything that flushes output buffering
      This list is by no means complete.


      The things that modify HTTP headers must come BEFORE things that force
      output of HTTP headers. session_start() may only be called once.


      Gordon L. Burditt

      Comment

      • Gordon Burditt

        #18
        Re: how do I fix this &quot; Warning: session_start() : Cannot send session cache limiter&quot;

        >> >But as I said earlier in the thread, PHP is giving me bum messages that[color=blue][color=green][color=darkred]
        >> >offer no illumination.[/color]
        >>
        >> They are telling you where the problem is. White space is a common,
        >> and difficult to find, but not the only cause of headers being sent.[/color]
        >
        >I think you are right, they are telling me where the problem is. I now
        >suspect the error was being triggered when this class method (which
        >sends a charset header) was called:[/color]

        The combination of header(), which sends a header,
        and ob_end_flush(), which forces the output, means you can't
        call session_start() after this function gets called.

        Gordon L. Burditt

        Comment

        • lawrence k

          #19
          Re: how do I fix this &quot; Warning: session_start() : Cannot send session cache limiter&quot;


          Gordon Burditt wrote:[color=blue][color=green][color=darkred]
          > >> >But as I said earlier in the thread, PHP is giving me bum messages that
          > >> >offer no illumination.
          > >>
          > >> They are telling you where the problem is. White space is a common,
          > >> and difficult to find, but not the only cause of headers being sent.[/color]
          > >
          > >I think you are right, they are telling me where the problem is. I now
          > >suspect the error was being triggered when this class method (which
          > >sends a charset header) was called:[/color]
          >
          > The combination of header(), which sends a header,
          > and ob_end_flush(), which forces the output, means you can't
          > call session_start() after this function gets called.[/color]

          Thanks much. I think you found the problem. My understanding of headers
          is shamefully weak. if I wanted to read up on how the headers work,
          would I read up on the http protocol or the IP protocol? I'm afraid
          right now I'm not even sure what category of information it is that I'm
          lacking.

          Comment

          • Gordon Burditt

            #20
            Re: how do I fix this &quot; Warning: session_start() : Cannot send session cache limiter&quot;

            >> >> >But as I said earlier in the thread, PHP is giving me bum messages that[color=blue][color=green][color=darkred]
            >> >> >offer no illumination.
            >> >>
            >> >> They are telling you where the problem is. White space is a common,
            >> >> and difficult to find, but not the only cause of headers being sent.
            >> >
            >> >I think you are right, they are telling me where the problem is. I now
            >> >suspect the error was being triggered when this class method (which
            >> >sends a charset header) was called:[/color]
            >>
            >> The combination of header(), which sends a header,
            >> and ob_end_flush(), which forces the output, means you can't
            >> call session_start() after this function gets called.[/color]
            >
            >Thanks much. I think you found the problem. My understanding of headers
            >is shamefully weak. if I wanted to read up on how the headers work,
            >would I read up on the http protocol or the IP protocol?[/color]

            HTTP. It's quite simple: a HTTP request consists of a request
            (typically GET or POST), followed by headers (if any), followed by
            a blank line, followed by a body (if any). A HTTP reply consists of
            a response line, followed by headers (if any), followed by a blank
            line, followed by a body (if any). You don't get to change the
            order. If you've already sent the blank line, it's too late to
            send more headers.
            [color=blue]
            >I'm afraid
            >right now I'm not even sure what category of information it is that I'm
            >lacking.[/color]

            Gordon L. Burditt

            Comment

            Working...