From 81e9068ebaf00a922f0fdda7184ded7319face25 Mon Sep 17 00:00:00 2001 From: "$(pass /github/name)" <$(pass /github/email)> Date: Fri, 20 Sep 2024 08:00:24 +0200 Subject: [PATCH] add: Cookie generation --- internal/utils/cookies.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 internal/utils/cookies.go diff --git a/internal/utils/cookies.go b/internal/utils/cookies.go new file mode 100644 index 0000000..1305fb3 --- /dev/null +++ b/internal/utils/cookies.go @@ -0,0 +1,20 @@ +package utils + +import ( + "net/http" + + "github.com/gin-gonic/gin" +) + +func SetCookie(c *gin.Context, token string) { + c.SetSameSite(http.SameSiteLaxMode) + c.SetCookie( + "jwt", + token, + 5*24*60*60, // 5 days + "/", + "", + true, + true, + ) +}