tough-cookie.cookiejar.deserializesync.md

July 9, 2025 ยท View on GitHub

Home > tough-cookie > CookieJar > deserializeSync

CookieJar.deserializeSync() method

A new CookieJar is created and the serialized Cookie values are added to the underlying store. Each Cookie is added via store.putCookie(...) in the order in which they appear in the serialization.

Note: Only works if the configured Store is also synchronous.

Signature:

static deserializeSync(strOrObj: string | SerializedCookieJar, store?: Store): CookieJar;

Parameters

Parameter

Type

Description

strOrObj

string | SerializedCookieJar

A JSON string or object representing the deserialized cookies.

store

Store

(Optional) The underlying store to persist the deserialized cookies into.

Returns:

CookieJar

Remarks

  • When no Store is provided, a new MemoryCookieStore will be used.

  • As a convenience, if strOrObj is a string, it is passed through JSON.parse first.