---
title: useShopifyCookies
description: Sets Shopify user and session cookies and refreshes the expiry time.
api_version: 2024-01
api_name: hydrogen
source_url:
html: 'https://shopify.dev/docs/api/hydrogen/2024-01/hooks/useshopifycookies'
md: 'https://shopify.dev/docs/api/hydrogen/2024-01/hooks/useshopifycookies.md'
---
# useShopifyCookies
Sets Shopify user and session cookies and refreshes the expiry time.
## useShopifyCookies([options](#useshopifycookies-propertydetail-options))
Manages Shopify cookies. If `hasUserConsent` option is false, Shopify cookies will be removed.
### Parameters
* options
UseShopifyCookiesOptions
### Returnsvoid
### UseShopifyCookiesOptions
* hasUserConsent
If set to \`false\`, Shopify cookies will be removed. If set to \`true\`, Shopify unique user token cookie will have cookie expiry of 1 year. Defaults to false.
```ts
boolean
```
* domain
The domain scope of the cookie. Defaults to empty string.
```ts
string
```
```ts
{
/**
* If set to `false`, Shopify cookies will be removed.
* If set to `true`, Shopify unique user token cookie will have cookie expiry of 1 year.
* Defaults to false.
**/
hasUserConsent?: boolean;
/**
* The domain scope of the cookie. Defaults to empty string.
**/
domain?: string;
}
```
### Examples
* #### Example code
##### Description
I am the default example
##### JavaScript
```jsx
import * as React from 'react';
import {useShopifyCookies} from '@shopify/hydrogen';
export default function App({Component, pageProps}) {
useShopifyCookies({hasUserConsent: false});
return ;
}
```
##### TypeScript
```tsx
import * as React from 'react';
import {useShopifyCookies} from '@shopify/hydrogen';
export default function App({Component, pageProps}) {
useShopifyCookies({hasUserConsent: false});
return ;
}
```
## Related
[Utility - sendShopifyAnalytics](https://shopify.dev/api/hydrogen/utilities/sendShopifyAnalytics)
[Utility - getClientBrowserParameters](https://shopify.dev/api/hydrogen/utilities/getclientbrowserparameters)
[Utility - getShopifyCookies](https://shopify.dev/api/hydrogen/utilities/getShopifyCookies)