---
title: set
summary: null
url: https://www.fastly.com/documentation/reference/vcl/statements/set
---

**Available in:** all subroutines

Sets the value of a variable or HTTP header.

```vcl
set var.custom_string_variable = "foo";
set obj.status = 307;
set obj.http.Location = "/login";
```

`set` will overwrite the value of an existing header (to append instead, see `add`). To set a single token in a comma-separated list of key-value pairs in the header value, `set` also supports subfield accessors:

```vcl
set resp.http.Cache-Control:max-age = "300";
set resp.http.Vary:Accept-Encoding = ""; # empty string adds "Accept-Encoding" to the header value as a standalone token
```

The `set` statement allows for a variety of operators:

| Operator         | Purpose           |
| ---------------- | ----------------- |
| `=`              | Simple assignment |
| `+=`             | Addition          |
| `-=`             | Subtraction       |
| `*=`             | Multiplication    |
| `/=`             | Division          |
| `%=`             | Remainder         |
| <code>\|=</code> | Bitwise OR        |
| `&=`             | Bitwise AND       |
| `^=`             | Bitwise XOR       |
| `<<=`            | Left shift        |
| `>>=`            | Right shift       |
