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.