Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

ios - Cookie sharing between multiple WKWebViews

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

First create a process pool once somewhere:

processPool = [[WKProcessPool alloc] 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];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...