cookieDelete method
Delete a cookie.
Implementation
void cookieDelete(String name, [String? path, String? domain]) {
if (_headersOutputted) {
throw StateError('Header already outputted');
}
try {
_logResponseCookie
.fine('delete: $name${path != null ? ' path=$path' : ''}');
// Normally, to delete a cookie, the value can be an empty string, but
// since Dart 2.1.0 (at least until and including Dart 2.2.0), the
// Cookie constructor throws a RangeError if passed an empty string.
// So the dummy value of "_DEL_" is used.
final delCookie = Cookie(name, '_DEL_')
..path = path
..domain = domain
..expires = DateTime.utc(1970, 1, 1, 0, 0, 1, 0)
..maxAge = 0;
return cookieAdd(delCookie);
// ignore: avoid_catching_errors
} on RangeError {
throw UnsupportedError(
'do not use Dart 2.1.x, 2.2.0: a bug prevents cookie deletion');
}
}