I have been doing some research but I am having an issue looking for correct syntax for a condition to create a cookie and store a URL as the value. If someone can help.
<?php
if (isset($_COOKIE['_ppc_cookie']) && ( created within 28 days ago)) {
$value=$_GET['afil']; // I think this adds the url into the value
setcookie("ppc_tracked_url", $value, strtotime( '+1 days' ));
}
?>
If a ppc cookie has been set (from an ad) and it was created within 28 days ago, set the URL as a value and create a cookie to capture the URL.
Any help appreciated. This is new to me.
I think you can't get a cookie's creation date. However you could put it's creation date inside the cookie on creation.
In order to do that make an array with your information and the creation date and serialize it. Then put the serialized data inside your cookie.
Now you just need to deserialize when you read your cookie.