note 50156 deleted from function.setcookie by bjori
| From: | bjori@php.net | Date: | Mon, 08 Jan 2007 10:43:12 +0000 |
| Subject: | note 50156 deleted from function.setcookie by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-121422@lists.php.net to get a copy of this message | ||
Note Submitter: Danny Lin
----
I have XP Home and IE6. I tried the example 3:
<?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";
}
}
?>
And it worked. However, when I added expiration info, it stopped working. Then, I noticed that it
might be related to the time() on my server (hosted in Texas). With the debugging code below, I
found out I have to add two hours. (You will need to "fresh" the browser to get the
cookies set.)
<?
for ($i = 0; $i < 10; $i++) {
$time[$i] = time();
setcookie("time_report[$i]",$time[$i], $time[$i]+3600*$i);
}
print_r($_COOKIE);
?>