> For the complete documentation index, see [llms.txt](https://rudderlabs.gitbook.io/rudderlabs-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rudderlabs.gitbook.io/rudderlabs-1/docs/stream-sources/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk/data-storage-cookies.md).

# Data Storage in Cookies

By default, the RudderStack JavaScript SDK stores persistent user data in the cookies. If the cookies are not supported, local storage is used instead.

All the cookies are stored in the top-level domain by default. It helps you to identify the users visiting from websites hosted under a particular sub-domain. For example, if you include the JavaScript SDK in both `admin.samplewebsite.com` and `app.samplewebsite.com`, the SDK will store the cookie in `samplewebsite.com`. However, you can configure where you want to store the cookie by using the `setCookieDomain` parameter in the `load` API options as shown:

```javascript
rudderanalytics.load(<WRITE_KEY>, <DATA_PLANE_URL>, {
  setCookieDomain: "samplewebsite.com",
});
```

## Cookies

The list of cookies used by the JavaScript SDK to store persistent user data is mentioned below:

<table><thead><tr><th>Name</th><th>Description</th><th>Example</th><th>Clearing mechanism using the SDK</th></tr></thead><tbody><tr><td><code>rl_user_id</code></td><td>Stores the user ID set via the <code>identify</code> API. All the subsequent event payloads will contain this data unless cleared from the storage.</td><td><code>4578</code>, <code>USER_001</code></td><td><code>rudderanalytics.reset()</code></td></tr><tr><td><code>rl_trait</code></td><td>Stores the user traits object set via the <code>identify</code> API. All the subsequent event payloads will contain this data unless cleared from the storage.</td><td><pre><code>{  email: "alex@example.com",  accountType: "pro",  country: "US",  someObj: {    key1: val1,    key2: val2,  }}
</code></pre></td><td><code>rudderanalytics.reset()</code></td></tr><tr><td><code>rl_anonymous_id</code></td><td>Stores the anonymous ID. By default, it would be the auto-generated unique ID by SDK for each visitor unless overridden via <code>setAnonymousId</code> API. All the subsequent event payloads will contain this data unless cleared from the storage.</td><td><code>5bfe258f-bd2f-49cf-bddd-8b844f74ab4b</code>, <code>customAnonId</code></td><td><code>rudderanalytics.reset(true)</code></td></tr><tr><td><code>rl_group_id</code></td><td>Stores the user group ID set via the <code>group</code> API. All the subsequent group event payloads will contain this data unless cleared from the storage.</td><td><code>GRP_3</code>, <code>98</code></td><td><code>rudderanalytics.reset()</code></td></tr><tr><td><code>rl_group_trait</code></td><td>Stores the user group traits object set via the <code>group</code> API. All the subsequent group event payloads will contain this data unless cleared from the storage.</td><td><pre><code>{  location: "New Orleans",  nationality: "US",  someObj: {    key1: val1,    key2: val2,  }}
</code></pre></td><td><code>rudderanalytics.reset()</code></td></tr><tr><td><code>rl_page_init_referrer</code></td><td>Stores the initial referrer of the page when a user visits a site for the first time. All the subsequent event payloads will contain this data.</td><td><code>https://www.google.com/</code></td><td>Cannot be cleared using SDK.</td></tr><tr><td><code>rl_page_init_referring_domain</code></td><td>Stores the initial referring domain of the page when a user visits a site for the first time. All the subsequent event payloads will contain this data.</td><td><code>google.com</code></td><td>Cannot be cleared using SDK.</td></tr><tr><td><code>test_rudder_cookie</code></td><td>Checks whether the cookie storage of a browser is accessible or not. Once checked, this cookie is removed immediately.</td><td><code>test_rudder_cookie:true</code></td><td>Cleared automatically.</td></tr></tbody></table>

The cookie values are encrypted and their length is directly proportional to the values provided to the SDK. Also, all the cookie names are prefixed with `rl_` and the values are prefixed with `RudderEncrypt:`. For example, `rl_user_id —> RudderEncrypt:U2FsdGVkX1+UKmiooYoGmKdNws7sgmWgGfHe`.

## Local storage cookies

The local storage cookies are used by the JavaScript SDK to keep track of the events sent to the RudderStack backend. They are listed in the table below:

<table><thead><tr><th>Name</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>ack</code></td><td>Timer for other browser tabs to claim control of the retry queue.</td><td><code>1639734070124</code></td></tr><tr><td><code>reclaimStart</code> and <code>reclaimEnd</code></td><td>Determines if a tab takes over the queue from another tab.</td><td><code>2dc2aee6-2836-4273-be69-79c90c04ddec</code></td></tr><tr><td><code>inProgress</code></td><td>Keeps track of the events in progress.</td><td><pre><code>{  "d89d7fb5-945e-4378-bda5-492e4b596fb4": {   "item": {    "url": "https://rudderstack-dataplane.rudderstack.com/v1/track",    "headers": {     "Content-Type": "application/json",      ...    },    "message": {      ...    }    "attemptNumber": 1,    "time": 1639734792773,    "id": "a4d89d7f-b594-4eb3-b8bd-a5492e4b596f"   }  }}
</code></pre></td></tr><tr><td><code>queue</code></td><td>Keeps track of the events that are in queue to be processed.</td><td><pre><code>[  {   "item": {    "url": "https://rudderstack-dataplane.rudderstack.com/v1/track",    "headers": {     "Content-Type": "application/json",      ...    },    "message": {      ...    }    "attemptNumber": 0,    "time": 1639734792773,    "id": "a4d89d7f-b594-4eb3-b8bd-a5492e4b596f"   }  }]
</code></pre></td></tr></tbody></table>

All the local storage cookie names are prefixed with `rudder.<uuid>.` For example, `rudder.2dc2aee6-2836-4273-be69-79c90c04ddec.reclaimEnd`.

## FAQ

Refer to the [FAQ](https://rudderstack.com/docs/stream-sources/rudderstack-sdk-integration-guides/rudderstack-javascript-sdk/js-sdk-faqs/) section for solutions to some of the commonly faced issues while using the JavaScript SDK on your website.

## Contact us

For more information or queries on this guide, you can [**contact us**](mailto:%20docs@rudderstack.com) or start a conversation in our [**Slack**](https://rudderstack.com/join-rudderstack-slack-community) community.
