deleteCookie method
- required WebUri url,
- required String name,
- String path = "/",
- String? domain,
- @Deprecated("Use webViewController instead") InAppWebViewController? iosBelow11WebViewController,
- InAppWebViewController? webViewController,
Removes a cookie by its name
for the given url
, domain
and path
.
The default value of path
is "/"
.
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 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.
The return value indicates whether the cookie was deleted successfully.
Note that it will return always true
for Web platform, iOS below 11.0 and MacOS below 10.13.
NOTE for iOS below 11.0 and MacOS below 10.13: 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!).
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 delete the cookie (session-only cookie and cookie with isHttpOnly
enabled won't be deleted!).
Officially Supported Platforms/Implementations:
- Android native WebView
- iOS (Official API - WKHTTPCookieStore.delete
- MacOS (Official API - WKHTTPCookieStore.delete
- Web
- Windows
Implementation
Future<bool> deleteCookie(
{required WebUri url,
required String name,
String path = "/",
String? domain,
@Deprecated("Use webViewController instead")
InAppWebViewController? iosBelow11WebViewController,
InAppWebViewController? webViewController}) =>
platform.deleteCookie(
url: url,
name: name,
path: path,
domain: domain,
iosBelow11WebViewController: iosBelow11WebViewController?.platform,
webViewController: webViewController?.platform);