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/");
}
}
I want to store the cookie on the user computer for 30 days, if the return i want to know the initial refereeing url.
But when i use this and lets say i go to another page in my site and then go back to the homepage its sets a new cookie with the exact same name and with the ref of the previous page.
Is there away to avoid this?