note 72830 added to function.time
| From: | djmute at abv dot bg | Date: | Fri, 02 Feb 2007 14:10:19 +0000 |
| Subject: | note 72830 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122559@lists.php.net to get a copy of this message | ||
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!
----
Server IP: 195.149.248.161
Probable Submitter: 83.228.1.226
----
Manual Page -- http://www.php.net/manual/en/function.time.php
Edit -- https://master.php.net/note/edit/72830
Del: integrated -- https://master.php.net/note/delete/72830/integrated
Del: useless -- https://master.php.net/note/delete/72830/useless
Del: bad code -- https://master.php.net/note/delete/72830/bad+code
Del: spam -- https://master.php.net/note/delete/72830/spam
Del: non-english -- https://master.php.net/note/delete/72830/non-english
Del: in docs -- https://master.php.net/note/delete/72830/in+docs
Del: other reasons-- https://master.php.net/note/delete/72830
Reject -- https://master.php.net/note/reject/72830
Search -- https://master.php.net/manage/user-notes.php