note 105738 added to function.setcookie
| From: | vanclute at gmail dot com | Date: | Sun, 11 Sep 2011 18:05:38 +0000 |
| Subject: | note 105738 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183096@lists.php.net to get a copy of this message | ||
I have been tearing my hair out wondering why a cookie would not delete. Despite countless
discussions of reasons this can happen all over the internet, none of them addresses my case. Here
is what was happening:
My cookies have been formed kindof as an array, and the name of the cookie to be deleted is being
passed in a variable, so I was using this to attempt to delete the cookie (stripped to the minimum
for simplicity of the example):
<?php
setcookie("$cookiename[id]");
?>
But it simply would not work. Ultimately what DID work was this:
<?php
setcookie($cookiename."[id]");
?>
So I had to concatenate the variable to the "element id" and then the cookies deleted
without any issue.
I hope this saves someone else from a sleepless night!!
Jonathan
----
Server IP: 69.147.83.197
Probable Submitter: 76.102.118.206
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit -- https://master.php.net/note/edit/105738
Del: integrated -- https://master.php.net/note/delete/105738/integrated
Del: useless -- https://master.php.net/note/delete/105738/useless
Del: bad code -- https://master.php.net/note/delete/105738/bad+code
Del: spam -- https://master.php.net/note/delete/105738/spam
Del: non-english -- https://master.php.net/note/delete/105738/non-english
Del: in docs -- https://master.php.net/note/delete/105738/in+docs
Del: other reasons-- https://master.php.net/note/delete/105738
Reject -- https://master.php.net/note/reject/105738
Search -- https://master.php.net/manage/user-notes.php