diff --git a/internal/config/session.go b/internal/config/session.go index 0b3454fa..990ca129 100644 --- a/internal/config/session.go +++ b/internal/config/session.go @@ -15,7 +15,7 @@ type Session struct { CookieEnabled bool CookieName string - CookieExpiration time.Time + CookieExpiration time.Duration CookieSecure bool } @@ -72,6 +72,6 @@ func (s *Session) Set() { s.CookieEnabled = viper.GetBool("session.cookie.enabled") s.CookieName = viper.GetString("session.cookie.name") - s.CookieExpiration = time.Now().Add(time.Duration(viper.GetInt("session.cookie.expiration")) * time.Hour) + s.CookieExpiration = time.Duration(viper.GetInt("session.cookie.expiration")) * time.Hour s.CookieSecure = viper.GetBool("session.cookie.secure") } diff --git a/internal/session/auth.go b/internal/session/auth.go index 06c40d6d..cc3be871 100644 --- a/internal/session/auth.go +++ b/internal/session/auth.go @@ -18,7 +18,7 @@ func (manager *SessionManagerCtx) CookieSetToken(w http.ResponseWriter, token st http.SetCookie(w, &http.Cookie{ Name: manager.config.CookieName, Value: token, - Expires: manager.config.CookieExpiration, + Expires: time.Now().Add(manager.config.CookieExpiration), Secure: manager.config.CookieSecure, SameSite: sameSite, HttpOnly: true,