fn

encodeCookieValue

v0.0.5

Percent-encodes only the characters a cookie value cannot contain per RFC 6265 (controls, whitespace, " , ; \ and % itself), leaving everything else readable. Compatible with js-cookie's default write converter.

Example

ts
encodeCookieValue('a=b; c'); // 'a=b%3B%20c'

Signature

ts
declare function encodeCookieValue(value: string): string;

Parameters

ParameterTypeDescription
valuestringThe raw cookie value

Returns

stringThe encoded cookie value