note 72830 deleted from function.time by nlopess
| From: | nlopess@php.net | Date: | Fri, 02 Feb 2007 16:51:47 +0000 |
| Subject: | note 72830 deleted from function.time by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-122568@lists.php.net to get a copy of this message | ||
Note Submitter: djmute at abv dot bg
----
Tested in PHP 4.4.4:
Take a look at these few rows.
<?php
$expire = time()+60*60*24*30;
setcookie('c_name', 'c_value', $expire, '/');
?>
<?php
$expire = mktime()+60*60*24*30;
setcookie('c_name', 'c_value', $expire, '/');
?>
<?php
setcookie('c_name', 'c_value', mktime()+60*60*24*30, '/');
?>
<?php
setcookie('c_name', 'c_value', time()+60*60*24*30, '/');
?>
At first sight they look the same, or at least leading to the same results. But not everything is
what it looks like.
Try it for yourself. The first 3 examples create the perfect cookie... Just the way we want it:
expiring in 30 days.
But the fourth... results in cookies having exp. date somewhere in 2020. Test it and reply please!