deleteCookie function
Delete a cookie from the client browser
Parameters:
event
: AnH4Event
instance containing the HTTP request.name
: The name of the cookie to delete.path
: Optional path of the cookie (must match the original cookie's path)domain
: Optional domain of the cookie (must match the original cookie's domain)
Example:
deleteCookie(event, 'auth_token');
Implementation
void deleteCookie(H4Event event, String name,
{String path = '/', String? domain}) {
final response = event.node["value"]?.response;
if (response == null) return;
final cookie = Cookie(name, '');
cookie.expires = DateTime(1970); // Set expiration to the past
cookie.maxAge = 0;
cookie.path = path;
if (domain != null) {
cookie.domain = domain;
}
response.cookies.add(cookie);
}