note 105738 deleted from function.setcookie by cmb

From: Date: Sun, 10 Nov 2019 12:51:00 +0000
Subject: note 105738 deleted from function.setcookie by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213007@lists.php.net to get a copy of this message
Note Submitter: vanclute at gmail dot com ---- 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

« previous php.notes (#213007) next »