I'm trying to set up a cookie, and this is the portion of the script it pertains to: echo "Makeing Cookie..."; setcookie("user", "$uname", time()+3600) or die("Cookie not made."); echo "Cookie Made."; Code (markup): For some reason, I'm getting this error: On line 10: <? Code (markup): I'm not sure what the problem is. Anyone help me please?
Cookies have to be set before anything is displayed in the browser. So if you have HTML, the php code has to go before it. If you echo or print anything with PHP, the cookie has to go first....Have to guess, since it's just a code snippet.
maybe you can check on line 10, because a single space can cause this error..so beware when you use sessions or cookies for your website.. easy example; <?php (there are no extra spaces here) <?php (but this one has extra spaces!) PHP: