-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
When either of the below cookie removal methods are used, Firefox warns the Cookie <name> has been rejected because it is already expired and it never removes the cookie. Chrome never removes the cookie either.
The workaround is to use cookies.set(), in the DELETE method, and pass both path and sameSite options to reflect values of the existing cookie.
I include path: '/', when creating the cookie in POST, because without it, the path would be set to /api.
Reproduction
https://github.com/j4w8n/cookie-bug
In a api/cookie/+server.js file:
- create a cookie in a POST request using
cookies.set(), including optionspathandsameSite - delete a cookie in a DELETE request using
cookies.delete(), orcookies.set()without thepathandsameSiteoptions.
General fyi, without passing the sameSite option with cookies.set() in step 2, Firefox will warn that the cookie is misusing the recommended SameSite attribute. Not that it's crucial, because we're trying to delete it anyway.
Logs
No response
System Info
System:
OS: macOS 12.5.1
CPU: (4) x64 Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz
Memory: 31.02 MB / 4.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - /usr/local/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 8.5.5 - /usr/local/bin/npm
Browsers:
Chrome: 105.0.5195.102
Firefox: 104.0.1
Safari: 15.6.1
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.71
@sveltejs/kit: next => 1.0.0-next.476
svelte: ^3.44.0 => 3.50.0
vite: ^3.1.0 => 3.1.0Severity
serious, but I can work around it
Additional Information
No response