diff options
| author | mo khan <mo@mokhan.ca> | 2025-04-30 15:06:55 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-04-30 15:06:55 -0600 |
| commit | 2ed3cc0a1a05c32fb7ecc32b02f3245c078b4baf (patch) | |
| tree | bfde739dc56a44088cc165a37d5f703b6e698afd /pkg/web/cookie/new.go | |
| parent | 9a21636ce6c7fd4100f18a4319c26c9420f7f6c7 (diff) | |
refactor: delegate to cookie.Reset to overload with options
Diffstat (limited to 'pkg/web/cookie/new.go')
| -rw-r--r-- | pkg/web/cookie/new.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/web/cookie/new.go b/pkg/web/cookie/new.go index c255818..b809b4e 100644 --- a/pkg/web/cookie/new.go +++ b/pkg/web/cookie/new.go @@ -64,6 +64,10 @@ func WithSameSite(value http.SameSite) x.Option[*http.Cookie] { func WithExpiration(expires time.Time) x.Option[*http.Cookie] { return With(func(c *http.Cookie) { c.Expires = expires - c.MaxAge = int(time.Until(expires).Seconds()) + if expires.Before(time.Now()) { + c.MaxAge = -1 + } else { + c.MaxAge = int(time.Until(expires).Seconds()) + } }) } |
