setcookie before content????
Quote:
Originally Posted by PHP.net
setcookie() defines a cookie to be 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). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace.
As some of you may know I recently authored my first real all PHP script on quotes.
Anyways, it was suggested that I use COOKIE instead of SESSION to preserve the history. I had thought about that and knew from javascript that cookies are tricky and that in PHP that they're easier in some respects and trickier in others.
It took me a little while to iron out the issues. However, in the process I discovered that the above is apparently not true. I hadn't really paid it any real attention until after I got things working. It was in the back of my mind though, so after things were working I reread it.
It just seems wrong. I'm using PHP 5.30 on a localhost Apache server via WAMP. I set the PHP cookies in the body of the page, and they work!
They also work on my live demo:
http://jscheuer1.comli.com/quotes/quote_c.php
Any ideas as to why?