function writeToCookie(items, c) {
  const cookieStr = items
    .map(item => `${item.sku}${QTY_SEP}${item.quantity}`)
    .join(ITEM_SEP);

  if (typeof document !== 'undefined') {
    // Client-side
    document.cookie = `${COOKIE}=${cookieStr}; path=/; SameSite=Lax; Secure`;
  } else if (c && c.headers) {
    // Server-side
    c.headers.set(
      'Set-Cookie',
      `${COOKIE}=${cookieStr}; path=/; SameSite=Lax; Secure`,
    );
  }
}
Writes the line items to the cookie.
@param {CookieLineItem[]} items - An array of items to write to the cookie.
@param {Request} c - The request object.