diff --git a/handler/admin.go b/handler/admin.go index 6b7ab7c..75c8f53 100644 --- a/handler/admin.go +++ b/handler/admin.go @@ -43,7 +43,7 @@ func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) { func (c *Controller) ServeLogout(w http.ResponseWriter, r *http.Request) { session := r.Context().Value("session").(*sessions.Session) - delete(session.Values, "user") + session.Options.MaxAge = -1 session.Save(r, w) http.Redirect(w, r, "/admin/login", http.StatusSeeOther) } diff --git a/handler/middleware.go b/handler/middleware.go index 94822a7..a94f4ce 100644 --- a/handler/middleware.go +++ b/handler/middleware.go @@ -121,7 +121,7 @@ func (c *Controller) WithUserSession(next http.HandlerFunc) http.HandlerFunc { http.Redirect(w, r, "/admin/login", http.StatusSeeOther) return } - // take username from sesion and add the user row + // take username from sesion and add the user row to the context user := c.GetUserFromName(username) if user.ID == 0 { // the username in the client's session no longer relates to a