I have some PHP code which checks on the HTTP Referer and sets a batch of cookies accordingly, it should detect what the HTTP referrer is and only set the cookies if its from an external source, so not on the current domain. Now it works and sets the cookies when I click from an external domain, but then when I click any internal site links all of the cookies (with the exception of the date set themselves blank. PHP is not my native language so any help would be appreciated?
My code looks like this:
$CheckURL = substr($_SERVER[HTTP_REFERER],7,21);
if($CheckURL <> "http://ift.tt/1CMConF" ) {
// external link so lets get the data
setcookie("XX_HTTP_First_2PHP", $varRefererCheck, time() + (86400 * 30), "/");
setcookie("XX_Source_First_2PHP", $varSource, time() + (86400 * 30), "/");
setcookie("XX_Medium_First_2PHP", $varMedium, time() + (86400 * 30), "/");
setcookie("XX_Campaign_First_2PHP", $varCampaign, time() + (86400 * 30), "/");
setcookie("XX_GCLID_First_2PHP", $vargclid, time() + (86400 * 30), "/");
setcookie("XX_First_Date_2PHP", date('l jS \of F Y h:i:s A'), time() + (86400 * 30), "/");
} else {
// Internal link do nothing!
}
Aucun commentaire:
Enregistrer un commentaire