To update and delete a cookie with JavaScript, we set the document.cookie
string.
For instance, we write
document.cookie = "username=Arnold";
to set document.cookie
to the cookie string with the key and value.
We remove the cookie by adding the expires
key and setting its value to a date in the past.
Conclusion
To update and delete a cookie with JavaScript, we set the document.cookie
string.