---
title: getShopifyCookies
description: Parses cookie string and returns Shopify cookies.
api_version: 2026-04
source_url:
  html: >-
    https://shopify.dev/docs/api/hydrogen-react/latest/utilities/getshopifycookies
  md: >-
    https://shopify.dev/docs/api/hydrogen-react/latest/utilities/getshopifycookies.md
---

# getShopifyCookies

Parses cookie string and returns Shopify cookies. For tracking values, consider using `getTrackingValues` instead, which reads from modern Shopify cookies.

## get​Shopify​Cookies(**[cookies](#getshopifycookies-propertydetail-cookies)**​)

Gets the values of \_shopify\_y and \_shopify\_s cookies from the provided cookie string. If the Shopify cookies doesn't exist, this method will return an empty string for each missing cookie.

### Parameters

* **cookies**

  **string**

  **required**

### Returns

* **ShopifyCookies**

### ShopifyCookies

Shopify cookies names

* \_shopify\_s

  Shopify session token: Value of \`\_shopify\_s\` cookie.

  ```ts
  string
  ```

* \_shopify\_y

  Shopify unique user token: Value of \`\_shopify\_y\` cookie.

  ```ts
  string
  ```

#### ShopifyCookies

Shopify cookies names

* **\_shopify\_s**

  **string**

  **required**

  Shopify session token: Value of `_shopify_s` cookie.

* **\_shopify\_y**

  **string**

  **required**

  Shopify unique user token: Value of `_shopify_y` cookie.

Examples

### Examples

* #### Example code

  ##### Description

  I am the default example

  ##### JavaScript

  ```jsx
  import * as React from 'react';
  import {useEffect} from 'react';
  import {getShopifyCookies} from '@shopify/hydrogen-react';

  export default function App({Component, pageProps}) {
    useEffect(() => {
      getShopifyCookies(document.cookie);
    });

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

  ##### TypeScript

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

  export default function App({Component, pageProps}) {
    useEffect(() => {
      getShopifyCookies(document.cookie);
    });

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

***

## Related

[- useShopifyCookies](https://shopify.dev/docs/api/hydrogen-react/2026-04/hooks/useshopifycookies)

[- getTrackingValues](https://shopify.dev/docs/api/hydrogen-react/2026-04/utilities/gettrackingvalues)

***
