note 41637 deleted from function.setcookie by nlopess

From: Date: Sat, 17 Apr 2004 19:44:15 +0000
Subject: note 41637 deleted from function.setcookie by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-68260@lists.php.net to get a copy of this message
Note Submitter: chris g ---- I just found this in a hard way: Do not add space(s) inside the brackets [ ] when setting up an array cookie or you will have a problem retrieving the value. // good setcookie( "cookie_name[$id]", $cookie_value ); // bad setcookie( "cookie_name[ $id ]", $cookie_value ); When you use foreach ($_COOKIE['cookie_name'] as $name => $value) { echo "$name : $value <br />\n"; } to get the value, both good and bad methods will return the value with no problem. But when you use $value = $cookie_name[ $id ]; only the good method (with no space) works. Weird eh?

« previous php.notes (#68260) next »