Alexander Kleinhans
Alexander Kleinhans

Reputation: 6248

Clear all cookies in NodeJS

This answer shows how to clear a single cookie in NodeJS. Is there a function to clear all cookies without iterating through all of them and clearing them (or expiring them) individually?

Upvotes: 1

Views: 2084

Answers (1)

Vikram Tiwari
Vikram Tiwari

Reputation: 3895

No, there isn't. According to RFC for Cookies, a server shouldn't sent multiple responses to clear cookie even.

If a server sends multiple responses containing Set-Cookie headers concurrently to the user agent (e.g., when communicating with the user agent over multiple sockets), these responses create a "race condition" that can lead to unpredictable behavior.

ALso, you should only be able to send one value for Set-Cookie, even in order to unset a cookie.

Read More: https://www.rfc-editor.org/rfc/rfc6265 [Pg 9]

Upvotes: 2

Related Questions