JS Cookies remove cookie, undefined
Hi Guys, I have trying to remove a cookie from a domain but I can’t, the console return undefined.
When I log in the cookie is set up in .dev.books.com but after that the URL change to platform.dev.books.com and keep the same cookies. The name of the cookie I want to remove is bookId, here is my try:
Cookies.set('bookId', ' ');
But instead to change the cookie value, create a new one with the domain platform.dev.books.com
If I use
Cookie.remove('bookId')
the console return undefined
Thanks, any help will be helpful
Advertisement
Answer
You can unset cookie and set the expire header time to a past date
document.cookie = "bookId=; expires=Thu, 01 Jan 1970 00:00:00 UTC";