1
0
Fork 0

Increase session cookies expiration

This commit is contained in:
Frédéric Guillot 2017-12-22 16:42:17 -08:00
parent 948e12c861
commit e4b4beabf0

View file

@ -13,9 +13,12 @@ import (
const ( const (
CookieSessionID = "sessionID" CookieSessionID = "sessionID"
CookieUserSessionID = "userSessionID" CookieUserSessionID = "userSessionID"
// Cookie duration in days.
cookieDuration = 30
) )
// New create a new cookie. // New creates a new cookie.
func New(name, value string, isHTTPS bool) *http.Cookie { func New(name, value string, isHTTPS bool) *http.Cookie {
return &http.Cookie{ return &http.Cookie{
Name: name, Name: name,
@ -23,6 +26,7 @@ func New(name, value string, isHTTPS bool) *http.Cookie {
Path: "/", Path: "/",
Secure: isHTTPS, Secure: isHTTPS,
HttpOnly: true, HttpOnly: true,
Expires: time.Now().Add(cookieDuration * 24 * time.Hour),
} }
} }