setcookie.delete_by_name

BOOLsetcookie.delete_by_nameIDwhereSTRINGcookie_name

Available inall subroutines.

Deletes a Set-Cookie header associated with the cookie_name contained in the HTTP response indicated by where. The beresp response is available in the vcl_fetch method, and the resp response is available in the vcl_deliver method.

Returns true if the Set-Cookie header was deleted, and returns false otherwise. If fmt is prefixed with !, returns true if the header was not deleted, and returns false if it was.

If multiple cookies of the same cookie_name are present in the response, then all of them will be deleted.

When this function does not have enough memory to succeed, the request is failed.

This function conforms to RFC 6265.

Examples

# use the result to control the flow of execution
sub vcl_fetch {
set beresp.http.Set-Cookie = "foo=bar";
if (!setcookie.delete_by_name(beresp, "foo")) {
// Do something if the Set-Cookie header associated with "foo" was not deleted
}
}
# ignore the result
sub vcl_deliver {
declare local var.ignored BOOL;
set resp.http.Set-Cookie = "bar=baz";
set var.ignored = setcookie.delete_by_name(resp, "bar");
# var.ignored is now true
}

User contributed notes

BETA

Do you see an error in this page? Do you have an interesting use case, example or edge case people should know about? Share your knowledge and help people who are reading this page! (Comments are moderated; for support, please contact Fastly support)