I am trying to create a simple web application with a username.
I found this feature in another post here.
func initSession(r *http.Request) *sessions.Session {
session, _ := store.Get(r, "mBoxStore")
if session.IsNew {
session.Options.Domain = "localhost"
session.Options.MaxAge = 10
session.Options.HttpOnly = false
session.Options.Secure = false
log.Println("Create New Session (cookie)")
} else {
log.Println("Use Old Session (old cookie)")
}
return session
}
The cookie expires after 10 seconds, but when I reload the page after, for example, 1 Minute
it uses the old (expired) cookie.
In my browser (Firefox) I see a cookie with an expiration date.
I think he should create a new session with a new cookie, or is it wrong?
any advice?
source
share