Closed mehrdad-shokri closed 5 years ago
write: document.cookie = "token=whatever"
Will this not remove other present cookies?
Nope, cookies are wierd. Setting document.cookie
will either add a new cookie or else overwrite an existing one if it has the same name (and path and domain...)
You probably want to set path=/
and domain=.your domain.com
to avoid having duplicates. And possibly the expiration date to make it last longer.
To delete a cookie, do the same thing but set the expiration date in the past.
This library only supports reading cookies. You can use the browser's built-in mechanisms for writing and deleting, or choose another library that does everything.
@nfriedly yeah, I ended up using js-cookie
alongside this project. Thank you
The README provides an example for reading.
const { token } = cookies(ctx)
how to write or delete a cookie?