Page 1 of 1

[SOLVED] Help on Cookie!

Posted: Tue Mar 22, 2005 7:10 am
by Phoenixheart
I can't find any documentation to help on this problem, so I post it here.

Code: Select all

<?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";
   }
}
?>
Everyone knows these code are in the php manual. But (at least as I know) they don't mention how to update the cookie. That means, how do I change the value in "cookie[two]" to "another_value" other than "cookietwo"? Or, how to delete the "cookie[one]" from the "cookie" array? Please help me out.


feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Tue Mar 22, 2005 7:30 am
by Chris Corbyn
Just set the cookie again with it's new value :wink:

To delete the cookie, set it's date in the past.