getCookies method

Future<List<Cookie>> getCookies({
  1. required WebUri url,
  2. @Deprecated("Use webViewController instead") InAppWebViewController? iosBelow11WebViewController,
  3. InAppWebViewController? webViewController,
})

Gets all the cookies for the given url.

webViewController is used for getting the cookies (also session-only cookies) using JavaScript (cookies with isHttpOnly enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the WebView managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work. In this case the url parameter is ignored.

NOTE for iOS below 11.0 and MacOS below 10.13: All the cookies returned this way will have all the properties to null except for Cookie.name and Cookie.value. If webViewController is null or JavaScript is disabled for it, it will try to use a PlatformHeadlessInAppWebView to get the cookies (session-only cookies and cookies with isHttpOnly enabled won't be found!).

NOTE for Web: this method will have effect only if the iframe has the same origin. If webViewController is null or JavaScript is disabled for it, it will try to use a PlatformHeadlessInAppWebView to get the cookies (session-only cookies and cookies with isHttpOnly enabled won't be found!).

Officially Supported Platforms/Implementations:

Implementation

Future<List<Cookie>> getCookies(
        {required WebUri url,
        @Deprecated("Use webViewController instead")
        InAppWebViewController? iosBelow11WebViewController,
        InAppWebViewController? webViewController}) =>
    platform.getCookies(
        url: url,
        iosBelow11WebViewController: iosBelow11WebViewController?.platform,
        webViewController: webViewController?.platform);