1900

Вытаскивание меток и реферера и запись в куки

<?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_medium", $utm_medium, $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("referer", $referer);
    }
?>

Комментарии

Комментировать