JavaScript Deleting Cookies

Javascript facilitates multiple ways of deleting cookies. These are as follows:

1. Delete the cookie by using the expire attribute

document.cookie = 'name=Mahesh; expires=Sun, 19 May 2019 18:04:55 UTC'

2. Delete the cookie by using the max-age attribute

document.cookie = 'name=Vishal; max-age=7200'

3. Delete cookie explicitly by using a web browser
Example:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<input type="button" value="set" onclick="setCookie()">
<input type="button" value="get" onclick="getCookie()">
<script>
function setCookie()
{
document.cookie="username = COOKIE;expires=Sun, 28 Nov 2018 13:15:00 UTC";
}
function getCookie()
{
if(document.cookie.length!=0)
{
alert(document.cookie);
}
else
{
alert("No Cookie here");
}
}
</script>
</body>
</html>