Load site based on cookie value in PHP

Viewed 65

I need to load site based on cookie, i write code to validate that like this.

if(!isset($_COOKIE['cookie'])){
    $domain = $_SERVER['SERVER_NAME'];
    setcookie('cookie','US', time() + 31536000, '/', $domain);
    header('Location: '.$_SERVER['REQUEST_URI']);   // reload
}

But when cookie created first time i got error.

enter image description here

0 Answers
Related