From d3fc94c2d21a26d06eae9053e9399aac9d57b9f3 Mon Sep 17 00:00:00 2001 From: Mats Engstrom Date: Mon, 4 Oct 2021 09:28:54 +0200 Subject: [PATCH 1/2] Allow Max-Age=0 to get real session cookies --- store.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/store.go b/store.go index eb45afb..bc057c1 100644 --- a/store.go +++ b/store.go @@ -204,14 +204,14 @@ var base32RawStdEncoding = base32.StdEncoding.WithPadding(base32.NoPadding) // Save adds a single session to the response. // -// If the Options.MaxAge of the session is <= 0 then the session file will be +// If the Options.MaxAge of the session is < 0 then the session file will be // deleted from the store path. With this process it enforces the properly // session cookie handling so no need to trust in the cookie management in the // web browser. func (s *FilesystemStore) Save(r *http.Request, w http.ResponseWriter, session *Session) error { - // Delete if max-age is <= 0 - if session.Options.MaxAge <= 0 { + // Delete if max-age is < 0 + if session.Options.MaxAge < 0 { if err := s.erase(session); err != nil { return err } From b5ee0564c3bcbcfc59526a4972f6011556caedac Mon Sep 17 00:00:00 2001 From: Mats Engstrom Date: Mon, 4 Oct 2021 09:31:28 +0200 Subject: [PATCH 2/2] Update mod to allow usage of this package from bergusdev --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 9028bcf..cbb6a41 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/gorilla/sessions +module github.com/bergusdev/sessions require github.com/gorilla/securecookie v1.1.1