setCookie method
void
setCookie(})
Sets the cookie with the given name and value in the response.
name
and value
must be composed of valid characters according to RFC
6265.
Implementation
void setCookie(
/// The name of the cookie.
String name,
/// The value of the cookie.
String value, {
/// The time at which the cookie expires.
DateTime? expires,
/// The number of seconds until the cookie expires. A zero or negative value
/// means the cookie has expired.
int? maxAge,
/// The domain that the cookie applies to.
String? domain,
/// The path within the [domain] that the cookie applies to.
String? path,
/// Whether to only send this cookie on secure connections.
bool secure = false,
/// Whether the cookie is only sent in the HTTP request and is not made
/// available to client side scripts.
bool httpOnly = true,
/// Whether the cookie is available from other sites.
SameSite? sameSite,
}) {
var cookie = Cookie(name, value)
..expires = expires
..maxAge = maxAge
..domain = domain
..path = path
..secure = secure
..httpOnly = httpOnly
..sameSite = sameSite;
var cookieHeaders = _binding.responseHeaders[HttpHeaders.setCookieHeader] ??= [];
cookieHeaders.add(cookie.toString());
}