Cookieintro
Cookieintro
Domain − The domain field provides the domain name of your site.
Path − It is the path to the directory or web page that set the cookie. This
can be left blank if you want to retrieve the cookie from any directory or
page.
Secure − If this field contains the word “secure”, then the cookie may
only be retrieved with a secure server. If this field is blank, there are no
such restrictions.
Name=Value − This depicts the cookies that are set and retrieved in the
form of key-value pairs.
function readAllCookies() {
let cookies = document.cookie;
console.log(cookies);
}
readAllCookies();
</script>
</head>
<body>
<h1>Read All Cookies</h1>
</body>
</html>
With JavaScript, you can change a cookie the same way as you create it:
document.cookie = "username=JJJ III; expires=Thu, 18 Dec 2013
12:00:00 UTC; path=/";