[PHP] $_session/$_cookie trouble
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? Thanks Gary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] $_session/$_cookie trouble
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.f...@leedsmet.ac.uk 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
Re: [PHP] $_session/$_cookie trouble
On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before your session_start(). Have you put your code before every include? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_session/$_cookie trouble
http://www.tech-recipes.com/rx/1489/solve-php-error-cannot-modify-header-information-headers-already-sent/ Regards, Igor Escobar Systems Analyst Interface Designer -- Personal Blog ~ blog.igorescobar.com Online Portifolio ~ www.igorescobar.com Twitter ~ @igorescobar On Tue, Apr 28, 2009 at 3:59 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before your session_start(). Have you put your code before every include? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_session/$_cookie trouble
Ashley Thanks for your reply, but no, that is not it. There was no other code prior. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240945179.3494.61.ca...@localhost.localdomain... On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before your session_start(). Have you put your code before every include? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_session/$_cookie trouble
On Tue, 2009-04-28 at 15:24 -0400, Gary wrote: Ashley Thanks for your reply, but no, that is not it. There was no other code prior. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240945179.3494.61.ca...@localhost.localdomain... On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before your session_start(). Have you put your code before every include? Ash www.ashleysheridan.co.uk The code is being pulled in from somewhere, have you checked to see if the framework you are using is pulling it in? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_session/$_cookie trouble
Igor Thanks for the link. It was suggested that I must put the session_start() before all code on the parent page. I am no longer getting the error messages,so I am assuming I am making progress, however I have yet to be able to get the $_SESSION or $_COOKIE to produce results...such as the ability to echo them. Thanks for your help. Gary Igor Escobar titiolin...@gmail.com wrote in message news:1f5251d50904281208g35fcc98t696b51a4bfc74...@mail.gmail.com... http://www.tech-recipes.com/rx/1489/solve-php-error-cannot-modify-header-information-headers-already-sent/ Regards, Igor Escobar Systems Analyst Interface Designer -- Personal Blog ~ blog.igorescobar.com Online Portifolio ~ www.igorescobar.com Twitter ~ @igorescobar On Tue, Apr 28, 2009 at 3:59 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before your session_start(). Have you put your code before every include? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_session/$_cookie trouble
Ashley There are 3 include files, the first is all html, but it has a form, so I put the session_start above the DTD and I no longer get the error messages. I had the session_start at the beginning of the second file, the php processing file, but that produced the error. It seemed to be calling to itself (if that does not sound too naive). As I mentioned in a post above, I am no longer getting the error message, but have been unable to get either the $_SESSION or the cookie to produce results... Thanks for your help. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240947209.3494.65.ca...@localhost.localdomain... On Tue, 2009-04-28 at 15:24 -0400, Gary wrote: Ashley Thanks for your reply, but no, that is not it. There was no other code prior. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240945179.3494.61.ca...@localhost.localdomain... On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before your session_start(). Have you put your code before every include? Ash www.ashleysheridan.co.uk The code is being pulled in from somewhere, have you checked to see if the framework you are using is pulling it in? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_session/$_cookie trouble
On Tue, 2009-04-28 at 15:34 -0400, Gary wrote: Ashley There are 3 include files, the first is all html, but it has a form, so I put the session_start above the DTD and I no longer get the error messages. I had the session_start at the beginning of the second file, the php processing file, but that produced the error. It seemed to be calling to itself (if that does not sound too naive). As I mentioned in a post above, I am no longer getting the error message, but have been unable to get either the $_SESSION or the cookie to produce results... Thanks for your help. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240947209.3494.65.ca...@localhost.localdomain... On Tue, 2009-04-28 at 15:24 -0400, Gary wrote: Ashley Thanks for your reply, but no, that is not it. There was no other code prior. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240945179.3494.61.ca...@localhost.localdomain... On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before your session_start(). Have you put your code before every include? Ash www.ashleysheridan.co.uk The code is being pulled in from somewhere, have you checked to see if the framework you are using is pulling it in? Ash www.ashleysheridan.co.uk There it is then. The HTML file causes the headers to be sent. Any output to the browser at all causes the headers to be sent, so any HTML or even spaces and newlines will trigger this error. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_session/$_cookie trouble
Thanks again, dont see any DOM As I mentioned I am no longer getting error message, but not sure it is working. I have this at the begining of the first file. ?php session_start(); setcookie('sale_cookie','$sale_value', time()-3600); setcookie('assess_cookie','$assess_value', time()-3600); if (isset($_COOKIE['sale_cookie']) isset($_COOKIE['assess_cookie'])) { $_SESSION['sale_value'] = $_COOKIE['sale_cookie']; $_SESSION['assess_value'] = $_COOKIE['assess_cookie']; } ? I have tried this echo $sale_value; echo $_SESSION['assess_value']; echo $_COOKIE['sale_cookie']; I have also removed all of the if() and still not had success None of which are producing results... Anyone see where I am going wrong... I have spent all day online, in the books, in the manual... Thanks again gary Igor Escobar titiolin...@gmail.com wrote in message news:1f5251d50904281318ie275b06w219fb6e014775...@mail.gmail.com... Make sure your file isn't a UTF-8 with DOM. Regards, Igor Escobar Systems Analyst Interface Designer -- Personal Blog ~ blog.igorescobar.com Online Portifolio ~ www.igorescobar.com Twitter ~ @igorescobar On Tue, Apr 28, 2009 at 5:13 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-04-28 at 15:34 -0400, Gary wrote: Ashley There are 3 include files, the first is all html, but it has a form, so I put the session_start above the DTD and I no longer get the error messages. I had the session_start at the beginning of the second file, the php processing file, but that produced the error. It seemed to be calling to itself (if that does not sound too naive). As I mentioned in a post above, I am no longer getting the error message, but have been unable to get either the $_SESSION or the cookie to produce results... Thanks for your help. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240947209.3494.65.ca...@localhost.localdomain... On Tue, 2009-04-28 at 15:24 -0400, Gary wrote: Ashley Thanks for your reply, but no, that is not it. There was no other code prior. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240945179.3494.61.ca...@localhost.localdomain... On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before your session_start(). Have you put your code before every include? Ash www.ashleysheridan.co.uk The code is being pulled in from somewhere, have you checked to see if the framework you are using is pulling it in? Ash www.ashleysheridan.co.uk There it is then. The HTML file causes the headers to be sent. Any output to the browser at all causes the headers to be sent, so any HTML or even spaces and
Re: [PHP] $_session/$_cookie trouble
On Tue, 2009-04-28 at 16:38 -0400, Gary wrote: Thanks again, dont see any DOM As I mentioned I am no longer getting error message, but not sure it is working. I have this at the begining of the first file. ?php session_start(); setcookie('sale_cookie','$sale_value', time()-3600); setcookie('assess_cookie','$assess_value', time()-3600); if (isset($_COOKIE['sale_cookie']) isset($_COOKIE['assess_cookie'])) { $_SESSION['sale_value'] = $_COOKIE['sale_cookie']; $_SESSION['assess_value'] = $_COOKIE['assess_cookie']; } ? I have tried this echo $sale_value; echo $_SESSION['assess_value']; echo $_COOKIE['sale_cookie']; I have also removed all of the if() and still not had success None of which are producing results... Anyone see where I am going wrong... I have spent all day online, in the books, in the manual... Thanks again gary Igor Escobar titiolin...@gmail.com wrote in message news:1f5251d50904281318ie275b06w219fb6e014775...@mail.gmail.com... Make sure your file isn't a UTF-8 with DOM. Regards, Igor Escobar Systems Analyst Interface Designer -- Personal Blog ~ blog.igorescobar.com Online Portifolio ~ www.igorescobar.com Twitter ~ @igorescobar On Tue, Apr 28, 2009 at 5:13 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-04-28 at 15:34 -0400, Gary wrote: Ashley There are 3 include files, the first is all html, but it has a form, so I put the session_start above the DTD and I no longer get the error messages. I had the session_start at the beginning of the second file, the php processing file, but that produced the error. It seemed to be calling to itself (if that does not sound too naive). As I mentioned in a post above, I am no longer getting the error message, but have been unable to get either the $_SESSION or the cookie to produce results... Thanks for your help. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240947209.3494.65.ca...@localhost.localdomain... On Tue, 2009-04-28 at 15:24 -0400, Gary wrote: Ashley Thanks for your reply, but no, that is not it. There was no other code prior. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240945179.3494.61.ca...@localhost.localdomain... On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before your session_start(). Have you put your code before every include? Ash www.ashleysheridan.co.uk The code is being pulled in from somewhere, have you checked to see if the framework you
Re: [PHP] $_session/$_cookie trouble
Take the values out of single quotes, else it sets them as strings, and not as the variable value. Also, are you meaning to set the cookie's expiration to time()-3600? Try time()+3600. On Tue, Apr 28, 2009 at 4:49 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2009-04-28 at 16:38 -0400, Gary wrote: Thanks again, dont see any DOM As I mentioned I am no longer getting error message, but not sure it is working. I have this at the begining of the first file. ?php session_start(); setcookie('sale_cookie','$sale_value', time()-3600); setcookie('assess_cookie','$assess_value', time()-3600); if (isset($_COOKIE['sale_cookie']) isset($_COOKIE['assess_cookie'])) { $_SESSION['sale_value'] = $_COOKIE['sale_cookie']; $_SESSION['assess_value'] = $_COOKIE['assess_cookie']; } ? I have tried this echo $sale_value; echo $_SESSION['assess_value']; echo $_COOKIE['sale_cookie']; I have also removed all of the if() and still not had success None of which are producing results... Anyone see where I am going wrong... I have spent all day online, in the books, in the manual... Thanks again gary Igor Escobar titiolin...@gmail.com wrote in message news:1f5251d50904281318ie275b06w219fb6e014775...@mail.gmail.com... Make sure your file isn't a UTF-8 with DOM. Regards, Igor Escobar Systems Analyst Interface Designer -- Personal Blog ~ blog.igorescobar.com Online Portifolio ~ www.igorescobar.com Twitter ~ @igorescobar On Tue, Apr 28, 2009 at 5:13 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-04-28 at 15:34 -0400, Gary wrote: Ashley There are 3 include files, the first is all html, but it has a form, so I put the session_start above the DTD and I no longer get the error messages. I had the session_start at the beginning of the second file, the php processing file, but that produced the error. It seemed to be calling to itself (if that does not sound too naive). As I mentioned in a post above, I am no longer getting the error message, but have been unable to get either the $_SESSION or the cookie to produce results... Thanks for your help. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240947209.3494.65.ca...@localhost.localdomain... On Tue, 2009-04-28 at 15:24 -0400, Gary wrote: Ashley Thanks for your reply, but no, that is not it. There was no other code prior. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240945179.3494.61.ca...@localhost.localdomain... On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before
Re: [PHP] $_session/$_cookie trouble
Make sure your file isn't a UTF-8 with DOM. Regards, Igor Escobar Systems Analyst Interface Designer -- Personal Blog ~ blog.igorescobar.com Online Portifolio ~ www.igorescobar.com Twitter ~ @igorescobar On Tue, Apr 28, 2009 at 5:13 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Tue, 2009-04-28 at 15:34 -0400, Gary wrote: Ashley There are 3 include files, the first is all html, but it has a form, so I put the session_start above the DTD and I no longer get the error messages. I had the session_start at the beginning of the second file, the php processing file, but that produced the error. It seemed to be calling to itself (if that does not sound too naive). As I mentioned in a post above, I am no longer getting the error message, but have been unable to get either the $_SESSION or the cookie to produce results... Thanks for your help. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240947209.3494.65.ca...@localhost.localdomain... On Tue, 2009-04-28 at 15:24 -0400, Gary wrote: Ashley Thanks for your reply, but no, that is not it. There was no other code prior. Gary Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1240945179.3494.61.ca...@localhost.localdomain... On Tue, 2009-04-28 at 10:48 -0400, Gary wrote: 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? Thanks Gary I would have thought it was obvious, the file assessresult.inc.php is being called before your session_start(). Have you put your code before every include? Ash www.ashleysheridan.co.uk The code is being pulled in from somewhere, have you checked to see if the framework you are using is pulling it in? Ash www.ashleysheridan.co.uk There it is then. The HTML file causes the headers to be sent. Any output to the browser at all causes the headers to be sent, so any HTML or even spaces and newlines will trigger this error. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_session/$_cookie trouble
Gary wrote: Thanks again, dont see any DOM As I mentioned I am no longer getting error message, but not sure it is working. I have this at the begining of the first file. ?php session_start(); setcookie('sale_cookie','$sale_value', time()-3600); setcookie('assess_cookie','$assess_value', time()-3600); if (isset($_COOKIE['sale_cookie']) isset($_COOKIE['assess_cookie'])) { $_SESSION['sale_value'] = $_COOKIE['sale_cookie']; $_SESSION['assess_value'] = $_COOKIE['assess_cookie']; } ? I have tried this echo $sale_value; echo $_SESSION['assess_value']; echo $_COOKIE['sale_cookie']; I have also removed all of the if() and still not had success None of which are producing results... Anyone see where I am going wrong... I have spent all day online, in the books, in the manual... Thanks again gary Looks to me like you are trying to set and retrieve a cookie on the same page. It doesn't work that way. Set it, access it on the next page... or, set it, and then redirect to the same page.. being sure to send a flag to hide the setcookie function to avoid the dreaded infinite loop. Also, Setting a cookie's expire param to history will delete it... so I don't think that is what you want to do. Donovan -- =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o D. BROOKE EUCA Design Center WebDNA Software Corp. WEB: http://www.euca.us | http://www.webdna.us =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o WebDNA: [** Square Bracket Utopia **] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_session/$_cookie trouble
Gary wrote: Thanks again, dont see any DOM As I mentioned I am no longer getting error message, but not sure it is working. I have this at the begining of the first file. ?php session_start(); setcookie('sale_cookie','$sale_value', time()-3600); setcookie('assess_cookie','$assess_value', time()-3600); if (isset($_COOKIE['sale_cookie']) isset($_COOKIE['assess_cookie'])) { $_SESSION['sale_value'] = $_COOKIE['sale_cookie']; $_SESSION['assess_value'] = $_COOKIE['assess_cookie']; } ? I have tried this echo $sale_value; echo $_SESSION['assess_value']; echo $_COOKIE['sale_cookie']; I have also removed all of the if() and still not had success None of which are producing results... Anyone see where I am going wrong... I have spent all day online, in the books, in the manual... Thanks again gary Maybe I'm missing something, but why are you using session vars and cookie vars like you are? If you start a session it creates a cookie to track the session and the session persists your session vars. Why not just use session vars? -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php