In Express.js, res.clearCookie() tells the browser to drop a cookie by sending a Set-Cookie header with an expiration date in the past. The cookie is cleared on the client after that response — the Node process does not erase the browser’s cookie jar directly.
Pass the same identifying options you used with res.cookie() (especially path and domain). Options such as expires and maxAge are ignored on clear. See the official cookie options for the full list.
Syntax
Call res.clearCookie in your Express.js app. Start with this line.
Required. Cookie name to clear (must match the name used in res.cookie).
options
Optional. Cookie attributes that should match the original cookie (for example path, domain, secure, sameSite). Do not rely on expires or maxAge — they are ignored.
Return Value
res.clearCookie() returns res for chaining. It instructs the browser to delete a cookie by sending an expired Set-Cookie.
One call per name. Each clearCookie queues another Set-Cookie header.
Same response. All three clear headers go out together with the status line.
Match each cookie’s options. If refreshToken used a custom path, pass that path on its clear call.
Empty body is fine.204 + end() completes logout without a JSON payload.
Compatibility
Runtime Support
res.clearCookie() is an Express.js response method. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers apply the expired Set-Cookie; they do not execute this method.
✓ Server · Express 4 & 5
res.clearCookie()
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers. Not available in the browser.
ServerNode.js runtime API
Node.js18+ for Express 5 · Express 4 supported
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
res.clearCookie()Express on Node.js
Bottom line: Study and run these examples with Node.js and the express package. Copy a snippet into a local file and start the server with node.
Frequently Asked Questions
It sends a Set-Cookie header that expires the named cookie in the past, so compliant browsers remove it. The server does not delete cookies from the browser’s store by itself.
Browsers clear a cookie only when attributes such as path and domain match the ones used when the cookie was set. Mismatched options often look like a silent failure.
No. Express ignores expires and maxAge on clearCookie completely. Do not rely on them to clear a cookie.
No. clearCookie only writes response headers. cookie-parser is for reading cookies on the request (req.cookies).
Call res.clearCookie() once per cookie name in the same response, then send your body or status.