Java Reference
In-Depth Information
A cookie can only be read by the domain that created it anyway, but doing this will allow all
subdomains of (such as and to
read it.
Secure Cookies
Adding "; secure" to the end of the cookie will ensure that it's only transmitted over a
secure HTTPS network:
document.cookie = "name=Batman; secure"
Deleting Cookies
To remove a cookie, simply set it to expire at a time in the past:
document.cookie = "name=Batman; expires=Thu, 01 Jan 1970
00:00:01 GMT"
If a cookie is a session cookie, it will expire when the tab or window is closed.
Note: A Cookie Library
JavaScript's cookie handling is quite basic and can also be quite cumber-
some. Many developers use a library such as Cookies.js or jsCookie. You
could even develop your own set of functions to make dealing with cookies
Search WWH ::

Custom Search