---
title: querystring.get
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/query-string/querystring-get
---

```
STRING querystring.get(STRING url, STRING name)
```

**Available in:** all subroutines

Returns the undecoded value associated with the query parameter `name` from the query component of `url`.

This expects that `url` is a valid URL and is URL-encoded. `name` is URL-encoded before searching and its value is returned as-is.

If the query component does not contain a value associated with `name`, then
`querystring.get` returns a _not set_ value. For example,
`querystring.get("/?a=1&b=2&c=3", "d")` is a _not set_ value.

If a query parameter associated with `name` is found but the value is absent,
then `querystring.get` returns the string `""`. For example,
`querystring.get("/?a=1&b=&c=3", "b")` is `""`.

If multiple query parameters of the same `name` are present in the query
component, then `querystring.get` returns the first value associated with
`name`. For example, `querystring.get("/?a=1&b=2&c=3&b=4&d=5", "b")` is `"2"`.

If the URL does not include a query component, then `querystring.get` returns a
_not set_ value. For example, `querystring.get("/", "a")` is a _not set_ value.

If `querystring.get` is called with _not set_ or empty string arguments, then it
returns a _not set_ value. For example, `querystring.get("", "")` is a not
set value.

To check if the return value is not an empty string or a _not set_ value, use the
`std.strlen()` function, which
returns `0` in both cases.

```vcl
if (std.strlen(querystring.get(req.url, "foo")) > 0) {
    // Do something if the value associated with "foo" is not an empty string
    // or a not set value.
}
```

This function conforms to the [URL Living Standard](https://url.spec.whatwg.org/).

## Examples

```vcl
querystring.get("/?foo=", "foo") # returns ""
querystring.get("", "") # returns a not set value
querystring.get("/?foo=&foo=bar", "foo") # returns ""
querystring.get("/?a=1&b=2&c=3&d=4", "b") # returns "2"
querystring.get("/?a=1", "b") # returns a not set value
querystring.get("/?foo", "foo") # returns a not set value
querystring.get("/?a=1&b=2&c=3&d=4&b=5", "b") # returns "2"
querystring.get(not set string, not set string) # returns a not set value
```
