WebKit2.CookieManager

g GObject.Object GObject.Object WebKit2.CookieManager WebKit2.CookieManager GObject.Object->WebKit2.CookieManager

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

add_cookie (cookie, cancellable, callback, *user_data)

add_cookie_finish (result)

delete_all_cookies ()

delete_cookie (cookie, cancellable, callback, *user_data)

delete_cookie_finish (result)

delete_cookies_for_domain (domain)

get_accept_policy (cancellable, callback, *user_data)

get_accept_policy_finish (result)

get_all_cookies (cancellable, callback, *user_data)

get_all_cookies_finish (result)

get_cookies (uri, cancellable, callback, *user_data)

get_cookies_finish (result)

get_domains_with_cookies (cancellable, callback, *user_data)

get_domains_with_cookies_finish (result)

replace_cookies (cookies, cancellable, callback, *user_data)

replace_cookies_finish (result)

set_accept_policy (policy)

set_persistent_storage (filename, storage)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Name

Short Description

changed

This signal is emitted when cookies are added, removed or modified.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class WebKit2.CookieManager(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

WebKit2.CookieManagerClass

Defines how to handle cookies in a WebKit2.WebContext.

The WebKit2.CookieManager defines how to set up and handle cookies. You can get it from a WebKit2.WebsiteDataManager with WebKit2.WebsiteDataManager.get_cookie_manager(), and use it to set where to store cookies with WebKit2.CookieManager.set_persistent_storage(), or to set the acceptance policy, with WebKit2.CookieManager.get_accept_policy().

Parameters:

Asynchronously add a Soup.Cookie to the underlying storage.

When the operation is finished, callback will be called. You can then call WebKit2.CookieManager.add_cookie_finish() to get the result of the operation.

New in version 2.20.

Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if the cookie was added or False in case of error.

Return type:

bool

Finish an asynchronous operation started with WebKit2.CookieManager.add_cookie().

New in version 2.20.

delete_all_cookies()

Delete all cookies of self.

Deprecated since version 2.16: Use WebKit2.WebsiteDataManager.clear() instead.

Parameters:

Asynchronously delete a Soup.Cookie from the current session.

When the operation is finished, callback will be called. You can then call WebKit2.CookieManager.delete_cookie_finish() to get the result of the operation.

New in version 2.20.

Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if the cookie was deleted or False in case of error.

Return type:

bool

Finish an asynchronous operation started with WebKit2.CookieManager.delete_cookie().

New in version 2.20.

delete_cookies_for_domain(domain)
Parameters:

domain (str) – a domain name

Remove all cookies of self for the given domain.

Deprecated since version 2.16: Use WebKit2.WebsiteDataManager.remove() instead.

get_accept_policy(cancellable, callback, *user_data)
Parameters:

Asynchronously get the cookie acceptance policy of self.

Note that when policy was set to WebKit2.CookieAcceptPolicy.NO_THIRD_PARTY and ITP is enabled, this will return WebKit2.CookieAcceptPolicy.ALWAYS. See also WebKit2.WebsiteDataManager.set_itp_enabled().

When the operation is finished, callback will be called. You can then call WebKit2.CookieManager.get_accept_policy_finish() to get the result of the operation.

get_accept_policy_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

the cookie acceptance policy of self as a WebKit2.CookieAcceptPolicy.

Return type:

WebKit2.CookieAcceptPolicy

Finish an asynchronous operation started with WebKit2.CookieManager.get_accept_policy().

get_all_cookies(cancellable, callback, *user_data)
Parameters:

Asynchronously get a list of Soup.Cookie from self.

When the operation is finished, callback will be called. You can then call WebKit2.CookieManager.get_all_cookies_finish() to get the result of the operation.

New in version 2.42.

get_all_cookies_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

A GLib.List of Soup.Cookie instances.

Return type:

[Soup.Cookie]

Finish an asynchronous operation started with WebKit2.CookieManager.get_all_cookies().

The return value is a GLib.SList of Soup.Cookie instances which should be released with g_list_free_full() and Soup.Cookie.free().

New in version 2.42.

get_cookies(uri, cancellable, callback, *user_data)
Parameters:

Asynchronously get a list of Soup.Cookie from self.

Asynchronously get a list of Soup.Cookie from self associated with uri, which must be either an HTTP or an HTTPS URL.

When the operation is finished, callback will be called. You can then call WebKit2.CookieManager.get_cookies_finish() to get the result of the operation.

New in version 2.20.

get_cookies_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

A GLib.List of Soup.Cookie instances.

Return type:

[Soup.Cookie]

Finish an asynchronous operation started with WebKit2.CookieManager.get_cookies().

The return value is a GLib.SList of Soup.Cookie instances which should be released with g_list_free_full() and Soup.Cookie.free().

New in version 2.20.

get_domains_with_cookies(cancellable, callback, *user_data)
Parameters:

Asynchronously get the list of domains for which self contains cookies.

When the operation is finished, callback will be called. You can then call WebKit2.CookieManager.get_domains_with_cookies_finish() to get the result of the operation.

Deprecated since version 2.16: Use WebKit2.WebsiteDataManager.fetch() instead.

get_domains_with_cookies_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

A None terminated array of domain names or None in case of error.

Return type:

[str]

Finish an asynchronous operation started with WebKit2.CookieManager.get_domains_with_cookies().

The return value is a None terminated list of strings which should be released with GLib.strfreev().

Deprecated since version 2.16: Use WebKit2.WebsiteDataManager.fetch_finish() instead.

replace_cookies(cookies, cancellable, callback, *user_data)
Parameters:

Asynchronously replace all cookies in self with the given list of cookies.

When the operation is finished, callback will be called. You can then call WebKit2.CookieManager.replace_cookies_finish() to get the result of the operation.

New in version 2.42.

replace_cookies_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if the cookies were added or False in case of error.

Return type:

bool

Finish an asynchronous operation started with WebKit2.CookieManager.replace_cookies().

New in version 2.42.

set_accept_policy(policy)
Parameters:

policy (WebKit2.CookieAcceptPolicy) – a WebKit2.CookieAcceptPolicy

Set the cookie acceptance policy of self as policy.

Note that ITP has its own way to handle third-party cookies, so when it’s enabled, and policy is set to WebKit2.CookieAcceptPolicy.NO_THIRD_PARTY, WebKit2.CookieAcceptPolicy.ALWAYS will be used instead. Once disabled, the policy will be set back to WebKit2.CookieAcceptPolicy.NO_THIRD_PARTY. See also WebKit2.WebsiteDataManager.set_itp_enabled().

set_persistent_storage(filename, storage)
Parameters:

Set non-session cookies.

Set the filename where non-session cookies are stored persistently using storage as the format to read/write the cookies. Cookies are initially read from filename to create an initial set of cookies. Then, non-session cookies will be written to filename when the WebKit2.CookieManager ::changed signal is emitted. By default, self doesn’t store the cookies persistently, so you need to call this method to keep cookies saved across sessions.

This method should never be called on a WebKit2.CookieManager associated to an ephemeral WebKit2.WebsiteDataManager.

Signal Details

WebKit2.CookieManager.signals.changed(cookie_manager)
Signal Name:

changed

Flags:

RUN_LAST

Parameters:

cookie_manager (WebKit2.CookieManager) – The object which received the signal

This signal is emitted when cookies are added, removed or modified.