SetCookie works on local not live

Hello

I’m trying to set up a cookie on my functions.php page. It all works fine on local or staging, but when I deploy live, the cookie is never set.

Does anyone know what might be wrong? My PHP is very basic as a f/e developer.

This is the function:

function needs_to_be_logged_in( $referer = “” )
{
$referer_url = “”;

if( $referer != "" )
{
	$referer_url = urlencode( $referer );
}

if( !ls_is_user_logged_in() )
{  
    $actual_link = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    setcookie("PageBeforeLogin", "$actual_link", time()+600, "/");
    header("Location:".home_url('/')."sign-in/?ReturnUrl=".$referer_url);
}

}

Thanks
James

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.