0

我想编写一个应用程序,让我从应用程序注册并发送发布请求并获得对 inappwebview 的响应,就像下面的考试一样

InAppWebView(
  initialUrl: widget.initUrls,
  initialOptions: InAppWebViewGroupOptions(
  crossPlatform: InAppWebViewOptions(
      mediaPlaybackRequiresUserGesture: false,
      debuggingEnabled: true,
    ),
  ),
  onWebViewCreated: (InAppWebViewController c){
    _controller = c;
    if(staticEmail != null && staticPass != null) {
      _controller.postUrl(url: "https://xxxxxxx.com/my-account", postData: utf8.encode(
          "email=${staticEmail}&password=${staticPass}&wooc_user_phone=${staticShop}&wooc_user_name=${staticShop}&woocommerce-register-nonce=5d1b626841&_wp_http_referer=/my-account/&register=Register") )
          .whenComplete(() => {print("done")}).catchError((err){print("err : ${err}");
            isloading = false;
          });
    }
  },
);

它登录正常。

但是当我转到另一个链接或当我关闭应用程序并再次登录时,它要求我再次登录我只想保存不会让我每次都登录的 cookie 或会话 ID

4

1 回答 1

0

您可以使用CookieManager这个flutter_inappwebview包来获取和设置cookies。这是插件使用的单例,您可以通过以下方式访问它:

CookieManager.instance()
于 2021-02-14T13:37:36.240 回答