Skip to content

Delete a Cookie with JavaScript

Advertisements

To delete a cookie, you just have to set the expires parameter to a passed date. Simple.

document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
Advertisements
See also  Detect browser tab close or refresh with JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.