Short expiry cookies depend on users having their system clocks set correctly.
Solution
Don't depend on the users having their clocks set right. Embed the timeout based on your server's
clock in the cookie.
- Code: Select all
<?php
$value = time()+3600 . ':' . $variable;
SetCookie('Cookie_Name',$value);
?>
Then when you receive the cookie, decode it and determine if it is still valid.
- Code: Select all
<?php
list($ts,$variable) = explode(':',$Cookie_Name,2);
if($ts < time()) {
...
} else {
SetCookie('Cookie_Name','');
}
?>