---
title: "Boxever.setCookie(cookieName, cookieValue[, expiresIn])"
slug: "bx-setcookie"
abstract: "Describes the setCookie() function in the Boxever JavaScript Library (Sitecore CDP Stream API)."
---
# Boxever.setCookie(cookieName, cookieValue\[, expiresIn\])

The `setCookie()` function creates a cookie in the browser.

## Parameters

| Parameter | Type | Description | Note |
| --- | --- | --- | --- |
| `cookieName` | string or number | The name of the cookie. | N/A |
| `cookieValue` | string | The value of the cookie. | N/A |
| `[expiresIn]`<br><br>optional | integer | The number of days before the cookie expires.<br><br>If you do not specify this value, the cookie becomes a [session cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#define_the_lifetime_of_a_cookie). | For example, set the value to `1` for the cookie to expire in 1 day. |

## Return value

undefined

## Example

Create a cookie in the browser that expires in 1 day:

```javascript
Boxever.setCookie("_example_cookie_name_", "_example_cookie_value_", 1);

```