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)
| 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. |
| 1128 | func (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. |