简体   繁体   中英

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?

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 (eg, 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://tools.ietf.org/html/rfc6265 [Pg 9]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM