diff --git a/cookie.go b/cookie.go index 9544953..e286920 100644 --- a/cookie.go +++ b/cookie.go @@ -14,7 +14,7 @@ func (c *cookie) get(ctx *fasthttp.RequestCtx, name string) []byte { return ctx.Request.Header.Cookie(name) } -func (c *cookie) set(ctx *fasthttp.RequestCtx, name string, value []byte, domain string, expiration time.Duration, secure bool, CookieSameSite fasthttp.CookieSameSite) { +func (c *cookie) set(ctx *fasthttp.RequestCtx, name string, value []byte, domain string, expiration time.Duration, secure bool, sameSite fasthttp.CookieSameSite) { cookie := fasthttp.AcquireCookie() cookie.SetKey(name) @@ -22,7 +22,7 @@ func (c *cookie) set(ctx *fasthttp.RequestCtx, name string, value []byte, domain cookie.SetHTTPOnly(true) cookie.SetDomain(domain) cookie.SetValueBytes(value) - cookie.SetSameSite(CookieSameSite) + cookie.SetSameSite(sameSite) if expiration >= 0 { if expiration == 0 { diff --git a/cookie_test.go b/cookie_test.go index 77175a3..7f2c9c0 100644 --- a/cookie_test.go +++ b/cookie_test.go @@ -72,6 +72,10 @@ func TestCookie_set(t *testing.T) { t.Errorf("cookie.set() Secure == %v, want %v", resultCookie.Secure(), secure) } + if resultCookie.SameSite() != fasthttp.CookieSameSiteLaxMode { + t.Errorf("cookie.set() SameSite == %v, want %v", resultCookie.SameSite(), samesite) + } + if v := ctx.Request.Header.Cookie(key); string(v) != string(value) { t.Errorf("cookie.set() request value == %s, want %s", v, value) }