function readFromCookie(c) {
  let cookieStr;

  if (typeof document !== 'undefined') {
    // Client-side
    cookieStr = document.cookie
      .split('; ')
      .find(row => row.startsWith(`${COOKIE}=`))
      ?.split('=')[1];
  } else if (c && c.headers) {
    // Server-side
    const cookieHeader = c.headers.get('cookie');
    cookieStr = cookieHeader
      ?.split('; ')
      .find(row => row.startsWith(`${COOKIE}=`))
      ?.split('=')[1];
  }

  if (!cookieStr) {
    return [];
  }

  return cookieStr.split(ITEM_SEP).map(item => {
    const [sku, quantity] = item.split(QTY_SEP);
    return { sku, quantity: parseInt(quantity, 10) };
  });
}
Reads the line items from the cookie.
@param {Request} c - The request object.
@returns {CookieLineItem[]} An array of items read from the cookie.