CookiePersistence Class

The persistent storage of the cookies of a CookieJar, e.g. a file or a database. The jar keeps the cookies in memory: it loads them with CookiePersistence.LoadCookies when it is created, and reports each change of a persistent cookie (a cookie with an expiry time), so that an implementation only stores the cookies.

public abstract class CookiePersistence

Remarks

A cookie is identified by its name, domain, host-only flag, path and partition key: CookiePersistence.SetCookie replaces the cookie with the same identity, and CookiePersistence.RemoveCookie removes it. The session cookies (without expiry time) are never stored, and a persisted cookie replaced by a session cookie is removed.

The methods are called synchronously, in the lock of the jar, by the responses and the scripts (document.cookie, cookieStore) of the browsing contexts that share the jar: an implementation must be thread-safe, and should buffer the changes and write them in the background (and expose a way to flush them). Its exceptions propagate to the caller of the jar. The changes are reported in order. The last access time of a cookie, which orders the eviction of the excess cookies, is persisted at most once a minute.

The loaded cookies are trusted (they are not parsed again), except that the cookies without domain or whose path does not start with / are ignored, and the expired cookies are removed. The expiry times are limited to 400 days.

Constructors

NameDescription
CookiePersistence()

CookiePersistence()

protected CookiePersistence()

No documentation is available.

Methods

NameDescription
ClearAll()Removes all the cookies (CookieJar.Clear).
LoadCookies()Returns the persisted cookies. The cookies without expiry time are loaded as session cookies (their changes are not persisted, and they are removed from the persistence when they are removed or replaced).
RemoveCookie(StoredCookie)Removes the cookie with the same identity (a cookie that is deleted, expired or evicted).
SetCookie(StoredCookie)Stores a persistent cookie: a new cookie, a cookie that replaces the cookie with the same identity, or a new last access time.

ClearAll()

Removes all the cookies (CookieJar.Clear).

public abstract void ClearAll()

LoadCookies()

Returns the persisted cookies. The cookies without expiry time are loaded as session cookies (their changes are not persisted, and they are removed from the persistence when they are removed or replaced).

public abstract IEnumerable<StoredCookie> LoadCookies()

RemoveCookie(StoredCookie)

Removes the cookie with the same identity (a cookie that is deleted, expired or evicted).

public abstract void RemoveCookie(StoredCookie cookie)

Parameters

cookie StoredCookie
The cookie.

SetCookie(StoredCookie)

Stores a persistent cookie: a new cookie, a cookie that replaces the cookie with the same identity, or a new last access time.

public abstract void SetCookie(StoredCookie cookie)

Parameters

cookie StoredCookie
The cookie.