InMemoryCookieStorage

public final actor InMemoryCookieStorage

A storage class for managing in-memory cookies.

  • Adds or updates a cookie in the storage.

    Declaration

    Swift

    public func setCookie(_ cookie: HTTPCookie)

    Parameters

    cookie

    The cookie to add or update.

  • Deletes a specific cookie from the storage.

    Declaration

    Swift

    public func deleteCookie(_ cookie: HTTPCookie)

    Parameters

    cookie

    The cookie to delete.

  • Deletes all cookies associated with a specific URL.

    Declaration

    Swift

    public func deleteCookies(url: URL)

    Parameters

    url

    The URL whose cookies should be deleted.

  • Retrieves all cookies currently stored.

    Declaration

    Swift

    public var cookies: [HTTPCookie]? { get }
  • Retrieves cookies associated with a specific URL.

    Declaration

    Swift

    public func cookies(for url: URL) -> [HTTPCookie]?

    Parameters

    url

    The URL to fetch cookies for.

  • Adds multiple cookies to the storage.

    Declaration

    Swift

    public func setCookies(_ cookies: [HTTPCookie], for url: URL?, mainDocumentURL: URL?)

    Parameters

    cookies

    The cookies to add.

    url

    The URL associated with the cookies (optional).

    mainDocumentURL

    The main document URL (optional).