Fri, 17 May 2024


How to make PHP cookies independant of the users clocks set right?

By: Anton, NetArt Media
Thu, 23 December 2021

You may use the following approach:

<?php
$value=(time+1800)+"|"+$YourData;
SetCookie("YourCookie",$value);
?>
...
<?php
list($ExpTime,$YourVariable)=explode("|","YourCookie",2);

if($ExpTime<time()){
...
}
else{
...
}

?>


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox