Destroy session as browser is closed. #1532
-
Hi, I've been trying to make my session invalid when the browser is closed, is it possible? |
Beta Was this translation helpful? Give feedback.
Answered by
TheBinaryGuy
Apr 27, 2024
Replies: 1 comment
-
Yeah kinda, just store the cookie with no expiry or max age and it'll get destroyed when the browser is closed. More info here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#define_the_lifetime_of_a_cookie As the MDN article points out, the "browser" defines when a session ends, and if the browser supports session restoration, it might persist across restarts. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dinogomez
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah kinda, just store the cookie with no expiry or max age and it'll get destroyed when the browser is closed.
More info here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#define_the_lifetime_of_a_cookie
As the MDN article points out, the "browser" defines when a session ends, and if the browser supports session restoration, it might persist across restarts.