0
我有一些PHP代碼,它檢查HTTP Referer並相應地設置一批cookie,它應該檢測HTTP引用者是什麼,並且只設置來自外部源的Cookie,所以不在當前域。現在,當我點擊外部域名時,它可以工作並設置cookie,但當我點擊任何內部網站鏈接所有cookie時(除了日期設置爲空白外,PHP不是我的母語,所以任何幫助都是讚賞在IF ELSE語句中設置PHP cookie
我的代碼如下:?
$CheckURL = substr($_SERVER[HTTP_REFERER],7,21);
if($CheckURL <> "www.sitesithere.co.uk") {
// 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!
}