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 <ash@xxxxxxxxxxxxxxxxxxxx> 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" <titiolinkin@xxxxxxxxx> wrote in message >> news:1f5251d50904281318ie275b06w219fb6e014775477@xxxxxxxxxxxxxxxxx >> > 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 >> > <ash@xxxxxxxxxxxxxxxxxxxx>wrote: >> > >> >> 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" <ash@xxxxxxxxxxxxxxxxxxxx> wrote in message >> >> > news:1240947209.3494.65.camel@xxxxxxxxxxxxxxxxxxxxxxxx >> >> > > 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" <ash@xxxxxxxxxxxxxxxxxxxx> wrote in message >> >> > >> news:1240945179.3494.61.camel@xxxxxxxxxxxxxxxxxxxxxxxx >> >> > >> > 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 >> >> >> >> >> > >> >> >> > Please don't top-post. > > As far as I know, the cookies are not actually set until the headers get > sent to the browser, and then you can read them again as cookie values > when the browser sends the cookie along with the page request. What > might be better is to use sessions only, which will save the session id > as part of the cookie/header. it's preferred unless you need to share > the cookie values with javascript that cannot interact with the php in > any way. > > > 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