summaryrefslogtreecommitdiff
path: root/pkg/web/cookie/new.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-04-15 17:46:34 -0600
committermo khan <mo@mokhan.ca>2025-04-15 17:46:34 -0600
commit655fb6c4cc180dfcbc13c1b85e0fbf47019caec0 (patch)
tree50aaf25e5c70697ed2c5f8c539bd331fdf11d721 /pkg/web/cookie/new.go
parent58276879a5505f8e37aa8f81d577b477b5497a53 (diff)
feat: create session cookie tied to access token
Diffstat (limited to 'pkg/web/cookie/new.go')
-rw-r--r--pkg/web/cookie/new.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/pkg/web/cookie/new.go b/pkg/web/cookie/new.go
new file mode 100644
index 0000000..2809640
--- /dev/null
+++ b/pkg/web/cookie/new.go
@@ -0,0 +1,22 @@
+package cookie
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/xlgmokha/x/pkg/env"
+)
+
+func New(name, value string, expires time.Time) *http.Cookie {
+ return &http.Cookie{
+ Name: name,
+ Value: value, // TODO:: digitally sign the value
+ Expires: expires,
+ MaxAge: int(time.Until(expires).Seconds()),
+ Path: "/",
+ // HttpOnly: true,
+ // Secure: true,
+ SameSite: http.SameSiteDefaultMode,
+ Domain: env.Fetch("HOST", "localhost"),
+ }
+}