RE: $_session/$_cookie trouble

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28 April 2009 15:48, Gary advised:

> I am trying to set a cookie and a session, but seem to be running into
a
> wall.
> 
> I have tried different variations, and keep getting the same error
message
> 
> If I have this
> 
> <?php
> 
> session_start();
> 
> I get this:
> Warning: session_start() [function.session-start]: Cannot send session
> cookie - headers already sent by (output started at
> C:\xampp\htdocs\weiss\assessresult.inc.php:2) in
> C:\xampp\htdocs\weiss\assessresult.inc.php on line 4
> 
> Warning: session_start() [function.session-start]: Cannot send session
> cache limiter - headers already sent (output started at
> C:\xampp\htdocs\weiss\assessresult.inc.php:2) in
> C:\xampp\htdocs\weiss\assessresult.inc.php on line 4
> 
> If I have this:
> session_start();
> 
> setcookie('sale_cookie','$sale_value', time()-3600);
> setcookie('assess_cookie','$assess_value', time()-3600);
> I get this
> 
> 
> Warning: session_start() [function.session-start]: Cannot send session
> cookie - headers already sent by (output started at
> C:\xampp\htdocs\weiss\assessresult.inc.php:2) in
> C:\xampp\htdocs\weiss\assessresult.inc.php on line 4
> 
> Warning: session_start() [function.session-start]: Cannot send session
> cache limiter - headers already sent (output started at
> C:\xampp\htdocs\weiss\assessresult.inc.php:2) in
> C:\xampp\htdocs\weiss\assessresult.inc.php on line 4
> 
> Warning: Cannot modify header information - headers already sent by
> (output started at C:\xampp\htdocs\weiss\assessresult.inc.php:2) in
> C:\xampp\htdocs\weiss\assessresult.inc.php on line 6
> 
> Warning: Cannot modify header information - headers already sent by
> (output started at C:\xampp\htdocs\weiss\assessresult.inc.php:2) in
> C:\xampp\htdocs\weiss\assessresult.inc.php on line 7
> 
> If I delete and start over, I stll get the "headers already sent"... I
> have tried numerous other variations, but all with the same error.
> 
> What am I missing here?

Whatever it is on line 2 of assessresult.inc.php that is causing output
to be started!

More seriously, there is something on line 2 of that file that is
causing something to be sent to the browser, which in turn causes the
http headers to be sent. Once those headers have been sent, nothing else
that wants to send headers, which includes starting the session and
setting cookies, can be done.

Either eliminate whatever it is on line 2 that is sending output, or
move the session_start() and/or setcookie() calls above it. (This early
in the file, prime candidate is actually a stray blank line outside your
<?php tag, but that's only a guess based on past experience of many
people in this list...!!)

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux