How to Clear and Remove User Cookies on Specific Web Pages


Cookies are important in knowing when a user is logged in and other important website functionality. So use this code with caution.

As an example, let's say the claim_listing cookie was stored as a user was attempting to claim a member listing.

In order to remove this cookie and stop the ability for the visitor to claim the listing as they continue to browse the website, you can include the snippet of code below on landing pages or web pages where you will not want the claim_listing cookie stored anymore.

<?php setcookieSameSite("claim_listing","", time-36000, "/", $_SERVER['HTTP_HOST'], true, true, "Lax"); ?>

Adding this code snippet on a widget will then clear and remove the claim_listing cookie.