deleteCookie method
- @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'CookieManager.getCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), IOSPlatform(apiName: 'WKHTTPCookieStore.delete', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', note: """On iOS below 11.0, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, 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. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). In this case, this method will return always `true`."""), MacOSPlatform(apiName: 'WKHTTPCookieStore.delete', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', note: """On macOS below 10.13, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, 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. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). In this case, this method will return always `true`."""), WebPlatform(note: """The [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, 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. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). In this case, this method will return always `true`."""), WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), LinuxPlatform(apiName: 'webkit_cookie_manager_delete_cookie', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.CookieManager.delete_cookie.html')])
- required WebUri url,
- required String name,
- String path = "/",
- String? domain,
- @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController,
- @SupportedPlatforms.new(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) PlatformInAppWebViewController? webViewController,
Removes a cookie by its name for the given url, domain and path.
The default value of path is "/".
The return value indicates whether the cookie was deleted successfully.
Officially Supported Platforms/Implementations:
- Android WebView (Official API - CookieManager.getCookie)
- iOS WKWebView (Official API - WKHTTPCookieStore.delete):
- On iOS below 11.0, the
webViewControlleris used for deleting the cookie (also session-only cookie) using JavaScript (cookie withisHttpOnlyenabled cannot be deleted, 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 delete the cookie (session-only cookie and cookie withisHttpOnlyenabled won't be deleted!). In this case, this method will return alwaystrue.
- On iOS below 11.0, the
- macOS WKWebView (Official API - WKHTTPCookieStore.delete):
- On macOS below 10.13, the
webViewControlleris used for deleting the cookie (also session-only cookie) using JavaScript (cookie withisHttpOnlyenabled cannot be deleted, 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 delete the cookie (session-only cookie and cookie withisHttpOnlyenabled won't be deleted!). In this case, this method will return alwaystrue.
- On macOS below 10.13, the
- Web <iframe> but requires same origin:
- The
webViewControlleris used for deleting the cookie (also session-only cookie) using JavaScript (cookie withisHttpOnlyenabled cannot be deleted, 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 delete the cookie (session-only cookie and cookie withisHttpOnlyenabled won't be deleted!). In this case, this method will return alwaystrue.
- 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_delete_cookie)
Parameters - Officially Supported Platforms/Implementations:
url: all platformsname: all platformspath: all platformsdomain: 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
@SupportedPlatforms(
platforms: [
AndroidPlatform(
apiName: 'CookieManager.getCookie',
apiUrl:
'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)',
),
IOSPlatform(
apiName: 'WKHTTPCookieStore.delete',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete',
note:
"""On iOS below 11.0, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript
(cookie with `isHttpOnly` enabled cannot be deleted, 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. JavaScript must be enabled in order to work.
In this case the [url] parameter is ignored.
If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView]
to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!).
In this case, this method will return always `true`.""",
),
MacOSPlatform(
apiName: 'WKHTTPCookieStore.delete',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete',
note:
"""On macOS below 10.13, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript
(cookie with `isHttpOnly` enabled cannot be deleted, 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. JavaScript must be enabled in order to work.
In this case the [url] parameter is ignored.
If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView]
to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!).
In this case, this method will return always `true`.""",
),
WebPlatform(
note:
"""The [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript
(cookie with `isHttpOnly` enabled cannot be deleted, 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. JavaScript must be enabled in order to work.
In this case the [url] parameter is ignored.
If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView]
to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!).
In this case, this method will return always `true`.""",
),
WindowsPlatform(
note:
'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.',
),
LinuxPlatform(
apiName: 'webkit_cookie_manager_delete_cookie',
apiUrl:
'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/method.CookieManager.delete_cookie.html',
),
],
)
Future<bool> deleteCookie({
required WebUri url,
required String name,
String path = "/",
String? domain,
@Deprecated("Use webViewController instead")
PlatformInAppWebViewController? iosBelow11WebViewController,
@SupportedPlatforms(
platforms: [
MacOSPlatform(),
IOSPlatform(),
WebPlatform(),
WindowsPlatform(),
],
)
PlatformInAppWebViewController? webViewController,
}) {
throw UnimplementedError(
'deleteCookie is not implemented on the current platform',
);
}