Removing Cookies In PHP

Removing Cookies In PHP If a user no longer needs a cookie that is stored on the user’s browser, then a user can instruct the browser to delete it. To delete a cookie, a user has to call setcookie() with the cookie name and any value (such as an empty string), and pass in an expires argument that is in the past. This immediately expires the cookie on the browser, ensuring that it is deleted. A user should also pass exactly the same path , domain , and other fields that they have used when they first created the cookie to ensure that the correct cookie is deleted:

setcookie( “fontSize”, “”, time() – 3600, “/”, “”, false, true );

Scroll to Top