Skip to main content

getShopifyCookies
utility

Parses cookie string and returns Shopify cookies.

If the Shopify cookies doesn't exist, this method will return empty string for each missing cookie.

string
required

ShopifyCookies

_shopify_y
string

Shopify unique user token: Value of _shopify_y cookie.

_shopify_s
string

Shopify session token: Value of _shopify_s cookie.

Was this section helpful?

Shopify cookies names

string
required

Shopify unique user token: Value of _shopify_y cookie.

string
required

Shopify session token: Value of _shopify_s cookie.

Was this section helpful?

Example code

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} />;
}