MCPcopy
hub / github.com/gin-gonic/gin / SetCookieData

Method SetCookieData

context.go:1128–1136  ·  view source on GitHub ↗

SetCookieData adds a Set-Cookie header to the ResponseWriter's headers. It accepts a pointer to http.Cookie structure for more flexibility in setting cookie attributes. The provided cookie must have a valid Name. Invalid cookies may be silently dropped.

(cookie *http.Cookie)

Source from the content-addressed store, hash-verified

1126// It accepts a pointer to http.Cookie structure for more flexibility in setting cookie attributes.
1127// The provided cookie must have a valid Name. Invalid cookies may be silently dropped.
1128func (c *Context) SetCookieData(cookie *http.Cookie) {
1129 if cookie.Path == "" {
1130 cookie.Path = "/"
1131 }
1132 if cookie.SameSite == http.SameSiteDefaultMode {
1133 cookie.SameSite = c.sameSite
1134 }
1135 http.SetCookie(c.Writer, cookie)
1136}
1137
1138// Cookie returns the named cookie provided in the request or
1139// ErrNoCookie if not found. And return the named cookie is unescaped.

Callers 1

TestContextSetCookieDataFunction · 0.80

Calls 1

SetCookieMethod · 0.80

Tested by 1

TestContextSetCookieDataFunction · 0.64