Hide/Show content based on cookie

An idea is to use some CSS if you want to apply this logic to many elements on different pages.

You can add this code to header.php for example :

if(!isset($_COOKIE["user_type"])) {
    <style>.hide_content {display:none!important}</style>
}

Then you can simply add the CSS class to all elements you want to hide when cookies are set.

Leave a Comment

error code: 523