This is a discussion on PHP - Better to echo the HTML headers? within the Windows Web Servers forums, part of the Web Server and Related Forums category; When starting sessions in PHP, if I send raw HTML headers before invoking session_start() I get the following warnings. Warning: ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
When starting sessions in PHP, if I send raw HTML headers before invoking
session_start() I get the following warnings. Warning: session_start(): Cannot send session cookie - headers already sent by ... on line 55 Warning: session_start(): Cannot send session cache limiter - headers already sent ... on line 55 However, if I first invoke session_start() before sending any HTML, the warnings aren't raised. I'm assuming that I can fiddle with php.ini to supress the warnings, but I'm wondering if it's always better (discounting the "double markup") to ehco the HTML headers in the same PHP block after the session_start() function. Maybe there are other fuctions besides session_start() that will throw warnings if the HTML headers are already set when they are invoked? |
|
|||
|
Kenneth Doyle wrote:
> When starting sessions in PHP, if I send raw HTML headers before invoking > session_start() > However, if I first invoke session_start() before sending any HTML, the You sound confused. There are two things to think about here: * The HTTP headers * The HTML document which will include a <head> element The <head> element has nothing to do with the HTTP headers. HTTP headers must be sent before the HTML document. The PHP session_start() function, among other things, sends a number of HTTP headers and thus must be called before any of the HTML document is sent. If this doesn't clear things up, you might want to rephrase your question (and use correct terminology). -- David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/> Home is where the ~/.bashrc is |
|
|||
|
David Dorward <dorward@yahoo.com> wrote in
news:cjnek7$ocg$2$8302bc10@news.demon.co.uk: > Kenneth Doyle wrote: > >> When starting sessions in PHP, if I send raw HTML headers before >> invoking session_start() > >> However, if I first invoke session_start() before sending any HTML, >> the > > You sound confused. There are two things to think about here: Yes, I was confused. What I meant by "raw HTML headers" was "any HTML code at all". > * The HTTP headers > * The HTML document which will include a <head> element .... > ... The PHP > session_start() function ... must be called before any of the HTML document is sent. > If this doesn't clear things up, you might want to rephrase your > question (and use correct terminology). No, it's clearer now; thanks. I have to keep reminding myself that this is ISAPI, not CGI. |