mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
cookie expiration as time duration.
This commit is contained in:
parent
0dd11fc1b7
commit
646b6ecaff
@ -15,7 +15,7 @@ type Session struct {
|
|||||||
|
|
||||||
CookieEnabled bool
|
CookieEnabled bool
|
||||||
CookieName string
|
CookieName string
|
||||||
CookieExpiration time.Time
|
CookieExpiration time.Duration
|
||||||
CookieSecure bool
|
CookieSecure bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +72,6 @@ func (s *Session) Set() {
|
|||||||
|
|
||||||
s.CookieEnabled = viper.GetBool("session.cookie.enabled")
|
s.CookieEnabled = viper.GetBool("session.cookie.enabled")
|
||||||
s.CookieName = viper.GetString("session.cookie.name")
|
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")
|
s.CookieSecure = viper.GetBool("session.cookie.secure")
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ func (manager *SessionManagerCtx) CookieSetToken(w http.ResponseWriter, token st
|
|||||||
http.SetCookie(w, &http.Cookie{
|
http.SetCookie(w, &http.Cookie{
|
||||||
Name: manager.config.CookieName,
|
Name: manager.config.CookieName,
|
||||||
Value: token,
|
Value: token,
|
||||||
Expires: manager.config.CookieExpiration,
|
Expires: time.Now().Add(manager.config.CookieExpiration),
|
||||||
Secure: manager.config.CookieSecure,
|
Secure: manager.config.CookieSecure,
|
||||||
SameSite: sameSite,
|
SameSite: sameSite,
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user