:right-sidebar: True CookieManager =================================================================== .. currentmodule:: gi.repository.WebKit .. class:: CookieManager(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Defines how to handle cookies in a :obj:`~gi.repository.WebKit.WebContext`. The WebKitCookieManager defines how to set up and handle cookies. You can get it from a :obj:`~gi.repository.WebKit.WebsiteDataManager` with webkit_website_data_manager_get_cookie_manager(), and use it to set where to store cookies with :func:`~gi.repository.WebKit.CookieManager.set_persistent_storage`, or to set the acceptance policy, with :func:`~gi.repository.WebKit.CookieManager.get_accept_policy`. Methods ------- .. rst-class:: interim-class .. class:: CookieManager :no-index: .. method:: add_cookie(cookie: ~gi.repository.Soup.Cookie, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None Asynchronously add a :obj:`~gi.repository.Soup.Cookie` to the underlying storage. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.WebKit.CookieManager.add_cookie_finish` to get the result of the operation. .. versionadded:: 2.20 :param cookie: the :obj:`~gi.repository.Soup.Cookie` to be added :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: add_cookie_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finish an asynchronous operation started with :func:`~gi.repository.WebKit.CookieManager.add_cookie`. .. versionadded:: 2.20 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: delete_cookie(cookie: ~gi.repository.Soup.Cookie, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None Asynchronously delete a :obj:`~gi.repository.Soup.Cookie` from the current session. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.WebKit.CookieManager.delete_cookie_finish` to get the result of the operation. .. versionadded:: 2.20 :param cookie: the :obj:`~gi.repository.Soup.Cookie` to be deleted :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: delete_cookie_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finish an asynchronous operation started with :func:`~gi.repository.WebKit.CookieManager.delete_cookie`. .. versionadded:: 2.20 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: get_accept_policy(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None Asynchronously get the cookie acceptance policy of ``cookie_manager``. Note that when policy was set to :const:`~gi.repository.WebKit.CookieAcceptPolicy.NO_THIRD_PARTY` and ITP is enabled, this will return :const:`~gi.repository.WebKit.CookieAcceptPolicy.ALWAYS`. See also webkit_website_data_manager_set_itp_enabled(). When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.WebKit.CookieManager.get_accept_policy_finish` to get the result of the operation. :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: get_accept_policy_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.WebKit.CookieAcceptPolicy Finish an asynchronous operation started with :func:`~gi.repository.WebKit.CookieManager.get_accept_policy`. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: get_all_cookies(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None Asynchronously get a list of :obj:`~gi.repository.Soup.Cookie` from ``cookie_manager``. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.WebKit.CookieManager.get_all_cookies_finish` to get the result of the operation. .. versionadded:: 2.42 :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: (closure user_data): a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: get_all_cookies_finish(result: ~gi.repository.Gio.AsyncResult) -> list[~gi.repository.Soup.Cookie] Finish an asynchronous operation started with :func:`~gi.repository.WebKit.CookieManager.get_all_cookies`. The return value is a :obj:`~gi.repository.GLib.List` of :obj:`~gi.repository.Soup.Cookie` instances which should be released with :func:`~gi.repository.GLib.List.free_full` and :func:`~gi.repository.Soup.Cookie.free`. .. versionadded:: 2.42 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: get_cookies(uri: str, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None Asynchronously get a list of :obj:`~gi.repository.Soup.Cookie` from ``cookie_manager``. Asynchronously get a list of :obj:`~gi.repository.Soup.Cookie` from ``cookie_manager`` 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 :func:`~gi.repository.WebKit.CookieManager.get_cookies_finish` to get the result of the operation. .. versionadded:: 2.20 :param uri: the URI associated to the cookies to be retrieved :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: get_cookies_finish(result: ~gi.repository.Gio.AsyncResult) -> list[~gi.repository.Soup.Cookie] Finish an asynchronous operation started with :func:`~gi.repository.WebKit.CookieManager.get_cookies`. The return value is a :obj:`~gi.repository.GLib.List` of :obj:`~gi.repository.Soup.Cookie` instances which should be released with :func:`~gi.repository.GLib.List.free_full` and :func:`~gi.repository.Soup.Cookie.free`. .. versionadded:: 2.20 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: replace_cookies(cookies: list[~gi.repository.Soup.Cookie], cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None Asynchronously replace all cookies in ``cookie_manager`` with the given list of ``cookies``. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.WebKit.CookieManager.replace_cookies_finish` to get the result of the operation. .. versionadded:: 2.42 :param cookies: a :obj:`~gi.repository.GLib.List` of :obj:`~gi.repository.Soup.Cookie` to be added :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: (closure user_data): a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: replace_cookies_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finish an asynchronous operation started with :func:`~gi.repository.WebKit.CookieManager.replace_cookies`. .. versionadded:: 2.42 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: set_accept_policy(policy: ~gi.repository.WebKit.CookieAcceptPolicy) -> None Set the cookie acceptance policy of ``cookie_manager`` as ``policy``. Note that ITP has its own way to handle third-party cookies, so when it's enabled, and ``policy`` is set to :const:`~gi.repository.WebKit.CookieAcceptPolicy.NO_THIRD_PARTY`, :const:`~gi.repository.WebKit.CookieAcceptPolicy.ALWAYS` will be used instead. Once disabled, the policy will be set back to :const:`~gi.repository.WebKit.CookieAcceptPolicy.NO_THIRD_PARTY`. See also webkit_website_data_manager_set_itp_enabled(). :param policy: a :obj:`~gi.repository.WebKit.CookieAcceptPolicy` .. method:: set_persistent_storage(filename: str, storage: ~gi.repository.WebKit.CookiePersistentStorage) -> None 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 WebKitCookieManager::changed signal is emitted. By default, ``cookie_manager`` 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 :obj:`~gi.repository.WebKit.CookieManager` associated to an ephemeral :obj:`~gi.repository.WebKit.WebsiteDataManager`. :param filename: the filename to read to/write from :param storage: a :obj:`~gi.repository.WebKit.CookiePersistentStorage` Signals ------- .. rst-class:: interim-class .. class:: CookieManager.signals :no-index: .. method:: changed() -> None This signal is emitted when cookies are added, removed or modified.