Create a new instance of CookieSerializer
The encryption instance for cookie operations
Encodes value as a plain cookie. By default, the plain value will be converted to a string using "JSON.stringify" method and then encoded as a base64 string.
You can disable cookie stringifaction by setting options.stringify = false
.
serializer.encode('name', 'virk')
serializer.encode('name', 'virk', { stringify: false })
The cookie key
The value to encode
Optional
options: Partial<CookieOptions & { encode: boolean; stringify: boolean }>Cookie encoding options
The serialized cookie string or null if encoding fails
Sign a key-value pair to a signed cookie. The signed value has a verification hash attached to it to detect data tampering.
The cookie key
The value to sign
Optional
options: Partial<CookieOptions>Cookie options
The serialized signed cookie string or null if signing fails
Encrypts a key-value pair to an encrypted cookie.
The cookie key
The value to encrypt
Optional
options: Partial<CookieOptions>Cookie options
The serialized encrypted cookie string or null if encryption fails
Cookies serializer is used to serialize a value to be set on the
Set-Cookie
header. You canencode
,sign
onencrypt
cookies using the serializer and then set them individually using theset-cookie
header.