Cookie Settings with Cloudflare

After my post

i created a new cookie through this code inside my header

but it’s work for the first time(correctly creating the cookie and redirect to homepage) and then stops to working.

How could i solve my issue? I already bypassed the page /enter in which the cookie is made.

currentURL = "https://" . _SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’];

if ( $currentURL == ‘’ ) :

setcookie( 'opt_in', from_italy_ok, time()+31556926, '/');
header( "refresh:1;url=" );