February 2018
Intermediate to advanced
298 pages
8h 22m
English
Let's take a look at how to access and set cookies using JavaScript:
Information found within a cookie is in the key=value; format. Let us create some cookies in the browser using the code snippet below:
document.cookie = "myFirstCookie=good;"document.cookie = "mySecondCookie=great;"console.log(document.cookie);
Warning: Strange behavior ahead!
What do you expect to be logged here? The answer is as follows:

Why, and why wasn't the document.cookie object overwritten? All will be explained in the next section.
Read now
Unlock full access