Skip to main content
Sitecore Documentation
  • Learn
  • Downloads
  • Changelog
  • Roadmap
CDPCloud Portal
Sitecore CDP Developer Documentation
  • Developing with Sitecore CDP
            • Boxever.eventCreate(event, callback, format)
            • Boxever.callFlows(flow, callback)
            • Boxever.addUTMParams(event)
            • Boxever.browserCreate(object, callback, format)
            • Boxever.browserShow(browserId, clientKey, callback, format)
            • Boxever.getBucketNumber([callback])
            • Boxever.getClientKey()
            • Boxever.getCookie(cookieName)
            • Boxever.getID()
            • Boxever.reset()
            • Boxever.setCookie(cookieName, cookieValue[, expiresIn])
            • Boxever.templating()
            • Boxever.triggerExperiences()
        • Troubleshooting
        • Release notes
  1. Functions
  1. Stream API
  2. Functions
  3. Boxever.setCookie(cookieName, cookieValue[, expiresIn])

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]

optional

integer

The number of days before the cookie expires.

If you do not specify this value, the cookie becomes a session 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:

Boxever.setCookie("_example_cookie_name_", "_example_cookie_value_", 1);
If you have suggestions for improving this article, let us know!

Documentation Assistant

This assistant uses AI to generate responses based on Sitecore documentation. While it has access to official sources, answers may be incomplete or inaccurate and should not be considered official advice or support.
Powered by
k
kapa.ai
Protected by reCAPTCHA

© Copyright 2026, Sitecore A/S or a Sitecore affiliated company.
All rights reserved.

Privacy policySitecore Trust CenterTerms of use