Cookie question

You can set the cookies on the two different pages by modifying your code to include the logic for setting the cookies when a user clicks on one of the options. Here’s the updated code:

function my_page_template_redirect() {

    if ( isset( $_COOKIE["landvanbartje_cookie"] ) ) {
        if( $_COOKIE["landvanbartje_cookie"] == "buiten_seizoen" ) {            
            wp_redirect( '/omgeving-rust-ruimte/' );
            exit;
        }
    }
    
    if ( isset( $_COOKIE["landvanbartje_cookie"] ) ) {
        if( $_COOKIE["landvanbartje_cookie"] == "familie" ) {            
            wp_redirect( '/homepage-gezinsvakantie/' );
            exit;
        }
    }

    if (isset($_GET['choice'])) {
        $choice = sanitize_text_field($_GET['choice']);

        if ($choice == "buiten_seizoen" || $choice == "familie") {
            setcookie("landvanbartje_cookie", $choice, time() + 3600, "https://wordpress.stackexchange.com/");
        }
    }
}

add_action( 'template_redirect', 'my_page_template_redirect' );

In this code, we’ve added a new check to see if a query parameter named ‘choice’ is set in the URL. If it’s set to either “buiten_seizoen” or “familie,” it will set the corresponding cookie with that value.

To set the cookies on the two different pages, you can provide links or buttons on those pages that include the ‘choice’ query parameter in the URL. For example, on the “Familie” page, you can add a link or button like this:

<a href="?choice=familie">Choose Familie</a>

And on the “Buiten seizoen” page:

<a href="?choice=buiten_seizoen">Choose Buiten seizoen</a>

When a user clicks on these links/buttons, the ‘choice’ query parameter will be included in the URL, and the code we added will set the corresponding cookie accordingly.

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino