getCookies method
- required WebUri url,
- @Deprecated("Use webViewController instead") InAppWebViewController? iosBelow11WebViewController,
- InAppWebViewController? webViewController,
Gets all the cookies for the given url.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - CookieManager.getCookie)
- iOS WKWebView (Official API - WKHTTPCookieStore.getAllCookies):
- On iOS below 11.0, the
webViewControlleris used for getting the cookies (also session-only cookies) using JavaScript (cookies withisHttpOnlyenabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of theWebViewmanaged by that controller. JavaScript must be enabled in order to work. In this case theurlparameter is ignored. All the cookies returned this way will have all the properties tonullexcept for Cookie.name and Cookie.value. IfwebViewControllerisnullor JavaScript is disabled for it, it will try to use a PlatformHeadlessInAppWebView to get the cookies (session-only cookies and cookies withisHttpOnlyenabled won't be found!).
- On iOS below 11.0, the
- macOS WKWebView (Official API - WKHTTPCookieStore.getAllCookies):
- On macOS below 10.13, the
webViewControlleris used for getting the cookies (also session-only cookies) using JavaScript (cookies withisHttpOnlyenabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of theWebViewmanaged by that controller. JavaScript must be enabled in order to work. In this case theurlparameter is ignored. All the cookies returned this way will have all the properties tonullexcept for Cookie.name and Cookie.value. IfwebViewControllerisnullor JavaScript is disabled for it, it will try to use a PlatformHeadlessInAppWebView to get the cookies (session-only cookies and cookies withisHttpOnlyenabled won't be found!).
- On macOS below 10.13, the
- Web <iframe> but requires same origin:
- The
webViewControlleris used for getting the cookies (also session-only cookies) using JavaScript (cookies withisHttpOnlyenabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of theWebViewmanaged by that controller. JavaScript must be enabled in order to work. In this case theurlparameter is ignored. IfwebViewControllerisnullor JavaScript is disabled for it, it will try to use a PlatformHeadlessInAppWebView to get the cookies (session-only cookies and cookies withisHttpOnlyenabled won't be found!).
- The
- Windows WebView2:
- The
webViewControllercould be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.
- The
- Linux WPE WebKit (Official API - webkit_cookie_manager_get_cookies)
Parameters - Officially Supported Platforms/Implementations:
url: all platformswebViewController:- macOS WKWebView
- iOS WKWebView
- Web <iframe> but requires same origin
- Windows WebView2
Use the PlatformCookieManager.isMethodSupported method to check if this method is supported at runtime.
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,
);