tough-cookie.cookie.tojson.md
May 3, 2024 ยท View on GitHub
Home > tough-cookie > Cookie > toJSON
Cookie.toJSON() method
For convenience in using JSON.stringify(cookie). Returns a plain-old Object that can be JSON-serialized.
Signature:
toJSON(): SerializedCookie;
Returns:
Remarks
-
Any
Dateproperties (such as Cookie.expires, Cookie.creation, and Cookie.lastAccessed) are exported in ISO format (Date.toISOString()). -
Custom Cookie properties are discarded. In tough-cookie 1.x, since there was no Cookie.toJSON() method explicitly defined, all enumerable properties were captured. If you want a property to be serialized, add the property name to Cookie.serializableProperties.