sessions icon indicating copy to clipboard operation
sessions copied to clipboard

How to delete session when the browser closed

Open im-here opened this issue 6 years ago • 4 comments

use cookie-based I want to delete session when the browser closed

im-here avatar Jan 23 '19 07:01 im-here

Did you finally find a solution?

Zhang-Siyang avatar Nov 22 '19 09:11 Zhang-Siyang

I have forgotten, reviewed the code, the backend is written like this:

store := cookie.NewStore([]byte(config.keyPairs))
store.Options(sessions.Options{
  MaxAge:0, // seems this works
  Path:   "/",
})

It seems to be processed in the frontend, when the browser is closed, delete the browser's cookie.

If you find a solution, remember to tell me, thanks!

im-here avatar Nov 22 '19 09:11 im-here

Maybe store the cookie on the client? Browsers session storage is cleared whenever user closes the tab

https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage

beniusij avatar Feb 23 '20 12:02 beniusij

Does anyone has update? We also encounter such problem and no perfect solution till now

jeven2016 avatar Feb 07 '23 03:02 jeven2016