delete a cookie in JavaScript

JavaScript
3
function deleteCookie(name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
🤖 Code Explanation
This code deletes a cookie with the given name. It sets the cookie's expiration date to be in the past, which causes the browser to delete it.

More problems solved in JavaScript




















