WordPress Redirect based on the prescence of a cookie

why not use the init action hook:

function has_my_cookie()
{
    if (!is_admin()){
        //Check to see if our cookie is set if not redirect to your desired page and set the cookie
        if ( !isset($_COOKIE["sevisitor"])) {
            //setcookie
            setcookie('sevisitor', 1, time()+1209600, "https://wordpress.stackexchange.com/", "http://localhost/child/", false);
             //Redirect 
            wp_redirect( get_site_url().'/about-myself' ); exit;
        }
    }
}
add_action('init', 'has_my_cookie');

Leave a Comment