encodeURIComponent()
to create the appropriate string.const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`;
serializeCookie('foo', 'bar'); // 'foo=bar'
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️