How to Clear and Remove User Cookies on Specific Web Pages

Link: https://support.brilliantdirectories.com/support/solutions/articles/12000098261

This article explains how to remove a specific cookie when a visitor accesses a particular page on the website.

Warning

Cookies are used to maintain important website functionality, such as user authentication and session data. Removing cookies may affect how certain features behave. Use this code only when the cookie is no longer needed.

For example, the claim_listing cookie is created when a visitor begins the process of claiming a member listing.

If the goal is to prevent the visitor from continuing the claim process after navigating to another page, the following code can be added to a landing page or widget to remove the claim_listing cookie.

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

Once this code is executed, the claim_listing cookie is cleared from the visitor's browser, preventing the claim process from continuing on subsequent pages.