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

# get​Shopify​Cookies

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

  ##### JavaScript

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

  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';

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

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

***

## Related

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

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

***
