> For the complete documentation index, see [llms.txt](https://developers.didomi.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.didomi.io/cmp/web-sdk/consent-notice/cookies.md).

# Cookies and storage

By default, the Didomi CMP uses first-party cookies to store consent information. Consent is stored in the base domain and shared across all the subdomains of the base domain where the SDK is deployed.

**Example:** If you install Didomi on `www.domain.com`, consents will be stored in a cookie on `.domain.com` and all sub-domains of `domain.com` will have access to the same consent information.

## Store consent on a different domain (subdomain)

If you want to store the first-party cookie on a specific sub-domain, you can add this option into the configuration.

Consents will be shared only to pages with this specific sub-domain.

```javascript
window.didomiConfig = {
  cookies: {
    local: {
      customDomain: 'privacy.your-domain.com'
    }
  }
};
```

## Cookie name

The Didomi SDK uses up to three cookies and local storage items for storing user consent:

* `didomi_token` for vendors and purposes in the token format (JSON format)
* `didomi_dcs` for vendors and purposes stored in the Didomi Consent String format (binary encoded)
* `euconsent-v2` for IAB TCF vendors and purposes (only for the GDPR regulation)

The name of the `didomi_token` , `didomi_dcs` and `euconsent-v2` cookies can be modified if you want to use a different name by setting the `cookies` property:

```javascript
window.didomiConfig = {
  cookies: {
    didomiTokenCookieName: 'custom_cookie_name', // didomi_token custom name
    iabCookieName: 'custom_iab_cookie_name', // euconsent-v2 custom name
    didomiConsentStringCookieName: 'custom_dcs_cookie_name' // didomi_dcs custom name
  }
};
```

Keep in mind that modifying the cookie name on a website that already had the Didomi SDK installed will re-collect consent. We recommend using a short cookie name.

## **Enable consent collection for different pages**

There may be a case where some pages on your website(s) do not belong to the same legal entity, but you want to collect consent on different pages, for example, displaying multiple notices on the website, with different vendors configuration, and local regulations, and save them "locally" and not at the domain level.

If you would like to separate consent between different sub-domains or pages inside the domain you can use custom cookie names to store the end-user consent status in different cookies / storage items. Custom cookie names should be configured in the `didomiConfig.cookies` property for a given page.&#x20;

Defining the custom cookie names used to store end-user consent will depend on whether your organization utilizes `didomi_token` or `didomi_dcs` ([Didomi Consent String](/cmp/didomi-consent-string.md)). Refer to the tabs for more information:

{% tabs %}
{% tab title="Didomi token" %}
If the web property utilizes the Didomi token (`didomi_token`) to store end-user consents your organization will need to define the custom cookie names for `didomiTokenCookieName` and `iabCookieName` for each web property.

{% code overflow="wrap" %}

```javascript
window.didomiConfig = {
  cookies: {
    didomiTokenCookieName: 'custom_cookie_name', // didomi_token custom name
    iabCookieName: 'custom_iab_cookie_name', // euconsent-v2 custom name
  }
};
```

{% endcode %}
{% endtab %}

{% tab title="Didomi Consent String" %}
If the web property utilizes the Didomi Consent String (`didomi_dcs`) to store end-user consents your organization will need to define the custom cookie names for `didomiConsentStringCookieName` and `iabCookieName` for each web property.

{% code overflow="wrap" %}

```javascript
window.didomiConfig = {
  cookies: {
    iabCookieName: 'custom_iab_cookie_name', // euconsent-v2 custom name
    didomiConsentStringCookieName: 'custom_dcs_cookie_name' // didomi_dcs custom name
  }
};
```

{% endcode %}
{% endtab %}
{% endtabs %}

Please have a look at the [Didomi Sandbox for Collecting Consent on Different Pages](https://sandbox.didomi.io/page-consent/index.html) to see how it works.

## Storage sources for user information

By default, the Web SDK stores user information and choices in both cookies and local storage. You can configure where user information and choices should be stored and use only cookies or local storage if you want to.

Set `cookies.storageSources.cookies` to `false` to disable storing data in cookies.\
Similarly, set `cookies.storageSources.localStorage` to `false` to disable storing data in local storage.

For instance, to configure the Web SDK to use local storage only:

```javascript
window.didomiConfig = {
  cookies: {
    storageSources: {
      cookies: false,
      localStorage: true
    }
  }
};
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developers.didomi.io/cmp/web-sdk/consent-notice/cookies.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
