SetCookie adds a Set-Cookie header to the ResponseWriter's headers. The provided cookie must have a valid Name. Invalid cookies may be silently dropped.
(name, value string, maxAge int, path, domain string, secure, httpOnly bool)
| 1107 | // The provided cookie must have a valid Name. Invalid cookies may be |
| 1108 | // silently dropped. |
| 1109 | func (c *Context) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool) { |
| 1110 | if path == "" { |
| 1111 | path = "/" |
| 1112 | } |
| 1113 | http.SetCookie(c.Writer, &http.Cookie{ |
| 1114 | Name: name, |
| 1115 | Value: url.QueryEscape(value), |
| 1116 | MaxAge: maxAge, |
| 1117 | Path: path, |
| 1118 | Domain: domain, |
| 1119 | SameSite: c.sameSite, |
| 1120 | Secure: secure, |
| 1121 | HttpOnly: httpOnly, |
| 1122 | }) |
| 1123 | } |
| 1124 | |
| 1125 | // SetCookieData adds a Set-Cookie header to the ResponseWriter's headers. |
| 1126 | // It accepts a pointer to http.Cookie structure for more flexibility in setting cookie attributes. |
no outgoing calls