note 87525 modified in function.setcookie by danbrown

From: Date: Sun, 17 May 2009 17:41:26 +0000
Subject: note 87525 modified in function.setcookie by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155012@lists.php.net to get a copy of this message
One note on storing information in an "array" in a cookie: You CANNOT access that array as a normal array. So for example if you store: <?php setcookie("cookie[three]", "cookiethree"); setcookie("cookie[two]", "cookietwo"); setcookie("cookie[one]", "cookieone"); $_COOKIE[cookie][one] returns nothing. ?> You MUST use foreach to grab all the information listed in the example above. Not sure if this is a bug in php or a "feature." Hopefully, this can save others some time. --was-- One note on storing information in an "array" in a cookie: You CANNOT access that array as a normal array. So for example if you store: setcookie("cookie[three]", "cookiethree"); setcookie("cookie[two]", "cookietwo"); setcookie("cookie[one]", "cookieone"); $_COOKIE[cookie][one] returns nothing. You MUST use foreach to grab all the information listed in the example above. Not sure if this is a bug in php or a "feature." Hopefully, this can save others some time. http://php.net/manual/en/function.setcookie.php

« previous php.notes (#155012) next »