This commit is contained in:
jdl committed 2024-12-08 09:45:29 +01:00
1 parent 55a9bf9dc3
commit 03ff1aac80
60 files changed
+3165 -2

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
package hub
import (
"net/http"
"time"
)
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.secure,
SameSite: http.SameSiteStrictMode,
MaxAge: 86400 * 365 * 10,
})
}
func (a *App) deleteCookie(w http.ResponseWriter, name string) {
http.SetCookie(w, &http.Cookie{
Name: name,
Value: "",
Path: "/",
Expires: time.Unix(0, 0),
})
}