From 1423b97542998ae1fc1510afa412a284ddfea18e Mon Sep 17 00:00:00 2001 From: James Elliott Date: Sun, 10 Jan 2021 02:21:07 +1100 Subject: [PATCH] [BUGFIX] Make Session Attribute Key Non Random (#33) * between v1 and v2 the session expiration attr key became a random value * this caused sessions generated in one app/daemon/etc to have expirations not aligning with others * this patch basically restores the functionality found in v1 * fixes #32 --- const.go | 1 + store.go | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/const.go b/const.go index cee1d94..6f45fa3 100644 --- a/const.go +++ b/const.go @@ -14,3 +14,4 @@ const defaultCookieLen uint32 = 32 // If set the cookie expiration when the browser is closed (-1), set the expiration as a keep alive (2 days) // so as not to keep dead sessions for a long time const keepAliveExpiration = 2 * 24 * time.Hour +const expirationAttrKey = "__store:expiration__" diff --git a/store.go b/store.go index eab11a8..6c38d7a 100644 --- a/store.go +++ b/store.go @@ -1,14 +1,9 @@ package session import ( - "fmt" "time" - - "github.com/savsgio/gotils/bytes" ) -var expirationAttrKey = fmt.Sprintf("__store:expiration:%s__", bytes.Rand(make([]byte, 5))) - // NewStore returns a new empty store func NewStore() *Store { return &Store{