unset cookie js code example
Example 1: javascript delete cookie
function deleteCookie(name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
Example 2: how to delete a cookie in js
//set the vvalue to EMPTY, and the date to an already PASSED one.
document.cookie = "cookiename= ; expires = Thu, 01 Jan 1970 00:00:00 GMT"
Example 3: clearing cookie in js
document.cookie.split(";")
.forEach(function(c) {
document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });