note 35791 deleted from function.setcookie by didou
| From: | didou@php.net | Date: | Mon, 22 Sep 2003 14:12:26 +0000 |
| Subject: | note 35791 deleted from function.setcookie by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-56909@lists.php.net to get a copy of this message | ||
Note Submitter: david.nospam@intulogic.net
----
I finally solved a huge problem I was having. I was setting a cookie using setcookie() like this:
setcookie ('mycookie','$cookievalue');
and I was wondering why my script kept saying that the cookie was invalid. Finally I debugged and
discovered that the value of $HTTP_COOKIE_VALS['mycookie'] was $cookievalue.
Like all such occurances, this one hit me like a bolt out of the blue. OF COURSE! I screamed - The
browser doesn't know the value of my variable - or even that it is a variable.
Never use SINGLE quotes around your PHP variables in the second argument of the setcookie()
function. They won't get interpolated, and you will be scratching your head like I was.