---
title: useShopifyCookies
description: Sets Shopify user and session cookies and refreshes the expiry time.
api_version: 2024-04
api_name: hydrogen
source_url:
  html: 'https://shopify.dev/docs/api/hydrogen/2024-04/hooks/useshopifycookies'
  md: 'https://shopify.dev/docs/api/hydrogen/2024-04/hooks/useshopifycookies.md'
---

# use​Shopify​Cookies

Sets Shopify user and session cookies and refreshes the expiry time.

## use​Shopify​Cookies(**[options](#useshopifycookies-propertydetail-options)**​)

Manages Shopify cookies. If `hasUserConsent` option is false, Shopify cookies will be removed.

### Parameters

* **options**

  **UseShopifyCookiesOptions**

### Returns**void**

### 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
  ```

Examples

### 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 <Component {...pageProps} />;
  }
  ```

  ##### TypeScript

  ```tsx
  import * as React from 'react';
  import {useShopifyCookies} from '@shopify/hydrogen';

  export default function App({Component, pageProps}) {
    useShopifyCookies({hasUserConsent: false});

    return <Component {...pageProps} />;
  }
  ```

## 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)
