package hub import ( "net/http" ) func (a *App) getCookie(r *http.Request, name string) string { if c, err := r.Cookie(name); err == nil { return c.Value } return "" } func (a *App) setCookie(w http.ResponseWriter, name, value string) { http.SetCookie(w, &http.Cookie{ Name: name, Value: value, Path: "/", Secure: !a.insecure, SameSite: http.SameSiteStrictMode, HttpOnly: true, MaxAge: 86400 * 21, }) } func (a *App) deleteCookie(w http.ResponseWriter, name string) { http.SetCookie(w, &http.Cookie{ Name: name, Value: "", Path: "/", Secure: !a.insecure, SameSite: http.SameSiteStrictMode, HttpOnly: true, MaxAge: -1, // delete now }) }