Cookie attributes not being set

The following is my code for setting a cookie with the builtin net/http. It sends the cookie just fine but doesn’t send any of the attributes along with it. I’m at a loss for why.

// provide token as cookie to frontend
ck := &http.Cookie{
	Name:  "token",
	Value: "test",
	Path:  "/",
	MaxAge:   int(time.Now().Add(time.Minute * 60).Unix()),
	HttpOnly: true,
	Secure:   true,
	SameSite: http.SameSiteLaxMode,
}
http.SetCookie(w, ck)

The header returned looks like such.

Set-Cookie: token=<valid token>

I’m expecting something more like this:

Set-Cookie: token=<valid token>; Path=/; Max-Age=3600; HttpOnly; Secure; SameSite=Lax

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.