Answer the question
In order to leave comments, you need to log in
Why does not remember Cookie and does not enter the value of the DB?
Hello!
I found the code for pulling out tags and writing to cookies, but why doesn’t it remember the value of $utm_source and doesn’t put it in the DB.
<?php
if (isset($_GET['utm_source'])){
$utm_source = $_GET['utm_source'];
$utm_medium = isset($_GET['utm_medium']) ? $_GET['utm_medium'] : '';
$utm_term = isset($_GET['utm_term']) ? $_GET['utm_term'] : '';
$utm_campaign = isset($_GET['utm_campaign']) ? $_GET['utm_campaign'] : '';
$referer = $_SERVER['HTTP_REFERER'];
$expire=time()+60*60*24*5;
$expire2=time()+60*5;
setcookie("utm_source", $utm_source, $expire);
setcookie("utm_term", $utm_term, $expire);
setcookie("utm_campaign", $utm_campaign, $expire);
setcookie("referer", $referer, $expire2);
header("HTTP/1.1 301 Moved Permanently");
header("Location: /");
}
if(!isset($_COOKIE['referer']))
{
$referer = $_SERVER['HTTP_REFERER'];
setcookie("referrer", $referrer);
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question