package api import ( "net/http" "time" ) func deleteCookie(w http.ResponseWriter, name string) { cookie := http.Cookie{ Name: name, Path: "/", MaxAge: -1, } http.SetCookie(w, &cookie) } func setAuthCookie(jwt string, domain string, w http.ResponseWriter) { setCookie(w, AuthCookieName, domain, jwt, int(time.Hour.Seconds()), http.SameSiteNoneMode) } func setCookie(w http.ResponseWriter, name string, domain string, value string, maxAge int, sameSite http.SameSite) { cookie := http.Cookie{ Name: name, Domain: domain, Value: value, Path: "/", HttpOnly: true, MaxAge: maxAge, Secure: true, SameSite: sameSite, } http.SetCookie(w, &cookie) } func getCookie(r *http.Request, name string) string { cookie, err := r.Cookie(name) if err != nil { return "" } return cookie.Value }