A cookie can only be read by the domain that created it anyway, but doing this will allow all
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"
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
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 ::