Cookie (çoğaltılmış) iki kez ayarlıyor

1 Cevap php

I'm new to cookies, and im trying to set a cookie where to store the referrer (the org ref).
But when i try this function:

function do_it_cookie() {

// Check if cookie exists
if (isset($_COOKIE['ref'])) {

    // It dose exist, do nothing or anything... 

    } else {
        setcookie ('ref', $_SERVER['HTTP_REFERER'], time() + 60, '/');
        header ("Location: http://www.nyttforetag.com/mind-your-own-business/");
    }
}

Ben istiyorum dönüş ilk hakem url bilmek ise, 30 gün boyunca kullanıcı bilgisayarında çerez saklamak istiyorum.

Ama bu kullanımı ve benim sitedeki başka bir sayfaya gidin diyelim ve daha sonra kendi setleri aynı adı taşıyan ve önceki sayfanın ref ile yeni bir çerez geri ana sayfasına gidin.

Bunu önlemek için uzak var mı?

1 Cevap

Şimdi 60 saniye boyunca mağazaları çerez.

time()+60*60*24*30 //this makes store it for 30 days.

dan php.net expire -

The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. In other words, you'll most likely set this with the time() function plus the number of seconds before you want it to expire. Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes)