Forum Moderators: coopster

Message Too Old, No Replies

$_COOKIE and $_SESSION in PHP

What have they got to do with headers?

         

dtmuk

11:58 pm on Jul 26, 2004 (gmt 0)

10+ Year Member



One of the only things that i've come across after coding in PHP for over 2 years now is the error:

Warning: Cannot modify header information - headers already sent by

i understand this when you are doing redirects using code such as:
<?
header("Location: );
exit;
?>

but what i don't understand is what $_SESSION's and $_COOKIES have got to do with the headers.

when i do a session_start for example when the page has been redirected to by the method above it brings up the error. Although if i supress the error with an '@' the script functions perfectly...

David Middlehurst

coopster

12:20 am on Jul 27, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, dtmuk!

Session management often involves the use of cookies. Cookies are sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). Please see RFC2965 [faqs.org] for additional information on how HTTP cookies work.

dtmuk

10:43 am on Jul 27, 2004 (gmt 0)

10+ Year Member



Thank you...

I understand now..!

David