2024-07-13 21:44:41 -04:00

29 lines
495 B
Go

package session
import (
"net/http"
"os"
"github.com/gorilla/sessions"
)
const (
MaxAge = 86400 * 30
IsProd = false
)
func New() sessions.Store {
key := os.Getenv("SESSION_SECRET")
if key == "" {
return nil
}
store := sessions.NewCookieStore([]byte(key))
store.MaxAge(MaxAge)
store.Options.Path = "/"
store.Options.HttpOnly = true
store.Options.Secure = IsProd
//store.Options.SameSite = http.SameSiteStrictMode
store.Options.SameSite = http.SameSiteLaxMode
return store
}