0

How do I remove or delete cookies when users close the browser? I have the code here using cookie-parser in NodeJS with the maxAge property which I do not know what value should I put in order to delete the cookie when users close the browser. I believe Many thanks in advance and greatly appreciated.

res.cookie('authcookie',accessToken,{maxAge:???,httpOnly:true})

Nat
  • 679
  • 1
  • 9
  • 24
  • Duplicate of [Clear cookies on browser close](https://stackoverflow.com/questions/1783302/clear-cookies-on-browser-close) – esqew Nov 18 '20 at 04:47

1 Answers1

3

If there is no Expires or Max-Age parameter set for the cookie, then the browser will treat is as a "session cookie" and will not store the cookie beyond the current browsing session (typically kept only in memory). So, when the browser is closed, the cookie will be gone.

jfriend00
  • 683,504
  • 96
  • 985
  • 979