export function set()

in packages/sdk/src/utils.ts [48:65]


  export function set(key: string, value: string, opt: Options = {}) {
    const parts = [`${encodeURIComponent(key)}=${encodeURIComponent(value)}`];
    if (opt.expires) {
      parts.push(`expires=${opt.expires.toUTCString()}`);
    } else if (typeof opt.maxAge === 'number') {
      parts.push(`expires=${new Date(Date.now() + opt.maxAge * 1000).toUTCString()}`);
    }
    if (opt.sameSite) {
      parts.push('samesite');
    }
    if (opt.domain) {
      parts.push(`domain=${encodeURIComponent(opt.domain)}`);
    }
    if (opt.secure) {
      parts.push('secure');
    }
    document.cookie = parts.join('; ');
  }