Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
287 views
in Q2A Core by

Hello there,

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', $cookie, time() + 31536000, '/', $domain);

header('Location: '.$_SERVER['REQUEST_URI']); // reload

}

But when cookie created first time i got error.

I think header('Location: '.$_SERVER['REQUEST_URI']); execute multiple times, How to fix this ? its that right way to do ? or any other thing i need to change ?

Please advise, Thank you

Please log in or register to answer this question.

...