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_s
string

Shopify session token: Value of _shopify_s cookie.

_shopify_y
string

Shopify unique user token: Value of _shopify_y cookie.

Was this section helpful?

Shopify cookies names

string
required

Shopify session token: Value of _shopify_s cookie.

string
required

Shopify unique user token: Value of _shopify_y cookie.

Was this section helpful?

Example code

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