--- title: useShopifyCookies description: Sets Shopify user and session cookies and refreshes the expiry time. api_version: 2025-07 api_name: hydrogen-react source_url: html: 'https://shopify.dev/docs/api/hydrogen-react/latest/hooks/useshopifycookies' md: >- https://shopify.dev/docs/api/hydrogen-react/latest/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 ### Returnsvoid ### UseShopifyCookiesOptions * checkoutDomain The checkout domain of the shop. Defaults to empty string. If set, the cookie domain will check if it can be set with the checkout domain. ```ts string ``` * domain The domain scope of the cookie. Defaults to empty string. ```ts string ``` * 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 ``` ```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; /** * The checkout domain of the shop. Defaults to empty string. If set, the cookie domain will check if it can be set with the checkout domain. */ checkoutDomain?: string; } ``` ### Examples * #### Example code ##### Description I am the default example ##### JavaScript ```jsx import * as React from 'react'; import {useShopifyCookies} from '@shopify/hydrogen-react'; export default function App({Component, pageProps}) { useShopifyCookies({hasUserConsent: false}); return ; } ``` ##### TypeScript ```tsx import * as React from 'react'; import {useShopifyCookies} from '@shopify/hydrogen-react'; export default function App({Component, pageProps}) { useShopifyCookies({hasUserConsent: false}); return ; } ``` ## Related [Utility - sendShopifyAnalytics](https://shopify.dev/api/hydrogen-react/utilities/sendShopifyAnalytics) [Utility - getClientBrowserParameters](https://shopify.dev/api/hydrogen-react/utilities/getclientbrowserparameters) [Utility - getShopifyCookies](https://shopify.dev/api/hydrogen-react/utilities/getShopifyCookies)