基于Cookie的重定向

I would like to set a cookie with an expiration time of 24 hours when a user enters Page A.

If the user visits Page B and he wasn't yet on Page A, he should stay on Page B.

However if the user visits Page B and the cookie from page A was already stored he should be automatically redirected to Page A.

Here is the PHP Code I inserted to the WP Plugin "My custom functions". Now my whole website ist just white and I can't do anything...

if( is_page('Page-A')){
    if(isset($_COOKIE['dz-offer'])){
        $cookie = $_COOKIE['dz-offer'];
    }
}
else{
    setcookie("dz-offer",time()+(3600*24));
    exit;
}

if( is_page('Page-B')){   
    if (!isset($_COOKIE['dz-cookie'])){
        header('Location: https://domain.com/page-a');
        exit;
    }
}
else{
   exit;
}

Any ideas how I can get that working? Thanks for your help!

+++ UPDATE +++

I deleted the Plugin "My custom functions" an now the white screen isn't there anymore... However if I reinstall the Plugin and activate it, the white space is there again before I can insert any code...