---
title: setcookie.delete_by_name
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/miscellaneous/setcookie-delete-by-name
---

```
BOOL setcookie.delete_by_name(ID where, STRING cookie_name)
```

**Available in:** all 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](https://tools.ietf.org/html/rfc6265).

## Examples

```vcl
# 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
  }
}
```

```vcl
# 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
}
```
