import Cookies from 'js-cookie'; export function parseCookie(cookie?: string) { const cookieObj: Record = {}; // Object to hold key-value pairs if (!cookie) { return cookieObj; } const cookieArr = cookie.split(';'); // Split cookie string into array of key-value pairs cookieArr.forEach(function (cookie) { const pair = cookie.split('='); // Split each pair into key and value const key = pair[0].trim(); // Remove whitespace from key const value = decodeURIComponent(pair[1]); // Decode value (optional) cookieObj[key] = value; // Add key-value pair to object }); return cookieObj; } export function setClientCookie({ key, value }: { key: string; value: any }) { Cookies.set(key, value, { expires: 365, }); }