# Cookies management

This page covers:

* `_fwn.cookies` Cookies consent API callbacks
* `cookies_opt_in` configuration to prevent any storage access until consent is given
* `cookies_root` configuration to prevent cookies being created at root domain

***

Firework widgets distinguish several cookie (local/session storage) categories.

* `essential`
* `functional`
* `performance`
* `targeting`

## Configuration <a href="#configuration" id="configuration"></a>

There are two implicit behaviors in which widgets can be configured - `opt-in` and `opt-out` (default).

#### Opt-out <a href="#opt-out" id="opt-out"></a>

Widget and Player uses cookies, local and session storages directly. This is a default behavior.

#### Opt-in <a href="#opt-in" id="opt-in"></a>

Widget and Player awaits for a consent to be given for each category to access user’s browser storages. Until then all storage data are kept in memory. Reloading page will cause storage data loss and user will refresh its identifiers.

To integrate widgets with opt-in strategy, integration must include `cookies_opt_in="true"` param on a script tag via data attribute `data-fwparam_cookies_opt_in`.

*Example:*

```html
<script
    src="//asset.fwcdn3.com/js/fwn.js" 
    data-fwparam_cookies_opt_in="true" 
    async
></script>

```

#### Root domain <a href="#root-domain" id="root-domain"></a>

Some cookies might be set on root domain to be accessible across subdomains. For example widget placed on `www.example.com` will attempt to set the same cookie to `.example.com` as well as `www.example.com`

The goal here is to be able to attribute purchase on `shop.example.com` to a video which was consumed on `live.example.com`. We understand such behavior might be undesired and can be disabled by add `cookies_root="false"` param to a global page configuration.

*Example of a script tag with global configuration:*

```html
<script
    src="//asset.fwcdn3.com/js/fwn.js"
    data-fwparam_cookies_root="false"
    async
></script>
```

## Managing consent <a href="#managing-consent" id="managing-consent"></a>

To grant or revoke particular consent at any time, `_fwn` web SDK provides several options:

* `_fwn.cookies.enableCookies` to grant consent for each given category
* `_fwn.cookies.disableCookies` to revoke consent for each given category
* `_fwn.cookies.setConsent` revokes all consents, then grants consent to each given category

All functions above accept comma separated list of consent categories or empty string to indicate all categories.

*Example:*

```javascript
// Grant consent to `essential` and `functional` categories 
_fwn.cookies.enableCookies('essential, functional') 

// Grant consent to all categories 
_fwn.cookies.enableCookies('') 

// Revoke all consents 
_fwn.cookies.disableCookies('') 

// Revoke all previously set consents, then set grant for new consent categories 
_fwn.cookies.setConsent('essential') 
```

## &#x20;<a href="#root-domain" id="root-domain"></a>


---

# 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.firework.com/firework-for-developers/web/integration-guide/privacy-settings/cookies-management.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.
