Files
server/auth/cookie.go
2026-04-11 18:53:48 +02:00

23 lines
467 B
Go

package auth
import (
"net/http"
)
// CookieMaxAge is the lifetime of the session cookie in seconds (7 days).
const CookieMaxAge = 7 * 24 * 60 * 60
const CookieName = "gotify-client-token"
func SetCookie(w http.ResponseWriter, token string, maxAge int, secure bool) {
http.SetCookie(w, &http.Cookie{
Name: CookieName,
Value: token,
Path: "/",
MaxAge: maxAge,
Secure: secure,
HttpOnly: true,
SameSite: http.SameSiteStrictMode,
})
}