From 4c7a5c570002c7076e0176847072d57751bdcb12 Mon Sep 17 00:00:00 2001 From: Mark Laing Date: Fri, 6 Jun 2025 09:44:02 +0100 Subject: [PATCH] pkg/http: Don't set MaxAge if cookie handler is request aware. The securecookie field can be nil. Expect the caller to set max age on the securecookie returned by the secureCookieFunc. Signed-off-by: Mark Laing --- pkg/http/cookie.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/http/cookie.go b/pkg/http/cookie.go index 6b87d3d..7724aeb 100644 --- a/pkg/http/cookie.go +++ b/pkg/http/cookie.go @@ -63,6 +63,10 @@ func WithSameSite(sameSite http.SameSite) CookieHandlerOpt { func WithMaxAge(maxAge int) CookieHandlerOpt { return func(c *CookieHandler) { c.maxAge = maxAge + if c.IsRequestAware() { + return + } + c.securecookie.MaxAge(maxAge) } }