cookieDelete method

void cookieDelete (String name, [ String path, String domain ])

Delete a cookie.

Implementation

void cookieDelete(String name, [String path, String domain]) {
  if (_headersOutputted) {
    throw new StateError("Header already outputted");
  }
  try {
    // 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 = new Cookie(name, "_DEL_")
      ..path = path
      ..domain = domain
      ..expires = new DateTime.utc(1970, 1, 1, 0, 0, 1, 0)
      ..maxAge = 0;
    return cookieAdd(delCookie);
    // ignore: avoid_catching_errors
  } on RangeError {
    throw new UnsupportedError(
        'do not use Dart 2.1.x, 2.2.0: a bug prevents cookie deletion');
  }
}