多个WKWebViews之间的Cookie共享 [英] Cookie sharing between multiple WKWebViews

查看:632
本文介绍了多个WKWebViews之间的Cookie共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中创建了一些WkWebViews,但是当为一个webview设置cookie时,它们不会在其他webview中生效(即其他webview不会将相同的cookie传递回服务器)。我怎样才能让他们使用相同的cookie存储?

I create a few WkWebViews in my app, but when cookies are set for one webview, they do not take effect in the other ones (i.e. the other webviews do not pass the same cookie back to the server). How can I get them to all use the same cookie storage?

推荐答案

通过对所有webview使用相同的WKProcessPool来实现这一点。

Got this working by using the same WKProcessPool for all the webviews.

首先在某处

processPool = [[WKProcessPool alloc] init];

然后在创建WKWebviews时使用它。该池必须在init方法中设置,而不是之后。

Then use it when creating WKWebviews. The pool must be set in the init method, not afterwards.

WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
config.processPool = processPool;
webview = [[WKWebView alloc] initWithFrame:frame configuration:config];

这篇关于多个WKWebViews之间的Cookie共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆