note 35791 added to function.setcookie
| From: | david dot nospam at intulogic dot net | Date: | Mon, 15 Sep 2003 01:36:45 +0000 |
| Subject: | note 35791 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56494@lists.php.net to get a copy of this message | ||
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 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.
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35791
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35791&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35791&report=yes