# readCookie

### `readCookie` Function

The `readCookie` function is used to **retrieve the value of a client-side first-party cookie** by its name.

#### Function Signature

```ts
this.readCookie(cookieName: string): string | null
```

#### Parameters

* **`cookieName`** (`string`, required):\
  The name of the cookie you want to read.

***

#### Return Value

* **If the cookie is found:** Returns the **cookie value** as a `string`.
* **If the cookie is not found:** Returns `null`.

***

#### Examples

**Example 1: Read an existing cookie**

```js
function() {
  var val = this.readCookie("JTS-RW");
  return val; // Value of the cookie
}
```

This example returns the value stored in the cookie named `JTS-RW`.

***

**Example 2: Read a non-existing cookie**

```js
function() {
  var val = this.readCookie("JTS-RW");
  return val; // null
}
```

This example attempts to read a cookie that does not exist. As a result, it returns `null`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.jentis.com/developer-guide/variables/client-side-variables/public-function-scope/readcookie.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
