Re: Cookies on WinXP
| From: | Steve Buehler | Date: | Fri, 01 Aug 2003 00:08:13 +0000 |
| Subject: | Re: Cookies on WinXP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-157844@lists.php.net to get a copy of this message | ||
Something else I found out now. I think it was Cpt John W. Holmes (not sure though) that said I couldn't have a cookie as an array like this the following. So i am not sure if it is something that is going away or not.
setcookie ("admin_access[host]", "$cookhost",0,"/","$cookhost");
setcookie ("admin_access[hostName]", "$hostName",0,"/","$cookhost");
But I found the following on the php site at:
http://us3.php.net/manual/en/function.setcookie.php
-----snip---------
* Cookies names can be set as array names and will be available to your PHP scripts as arrays but seperate cookies are stored on the users system. Consider <http://us3.php.net/manual/en/function.explode.php>explode() or <http://us3.php.net/manual/en/function.serialize.php>serialize() to set one cookie with multiple names and values.
<?php
// set the cookies
setcookie ("cookie[three]", "cookiethree");
setcookie ("cookie[two]", "cookietwo");
setcookie ("cookie[one]", "cookieone");
// after the page reloads, print them out
if (isset($_COOKIE['cookie'])) {
foreach ($_COOKIE['cookie'] as $name => $value) {
echo "$name : $value <br />\n";
}
}
/* which prints
three : cookiethree
two : cookietwo
one : cookieone
*/
?>
---------end snip--------
I want to thank everybody for your help.
Thanks
Steve