Browse Source

clear the cookie properly

main
Stephanie Gredell 6 months ago
parent
commit
4d1784388a
  1. 8
      handlers/auth.go
  2. BIN
      tmp/main

8
handlers/auth.go

@ -56,6 +56,7 @@ func (h *Handler) Logout(w http.ResponseWriter, r *http.Request) { @@ -56,6 +56,7 @@ func (h *Handler) Logout(w http.ResponseWriter, r *http.Request) {
// Clear the session data
session.Values = make(map[interface{}]interface{})
session.Options.MaxAge = -1
// Save the empty session
err = session.Save(r, w)
@ -63,12 +64,5 @@ func (h *Handler) Logout(w http.ResponseWriter, r *http.Request) { @@ -63,12 +64,5 @@ func (h *Handler) Logout(w http.ResponseWriter, r *http.Request) {
return
}
http.SetCookie(w, &http.Cookie{
Name: "user-session", // or whatever your session name is
Value: "",
Path: "/",
MaxAge: -1, // This deletes the cookie
})
http.Redirect(w, r, "/", http.StatusFound)
}

BIN
tmp/main

Binary file not shown.
Loading…
Cancel
Save