Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cookie的设置 #48

Closed
Jing2684 opened this issue Sep 30, 2019 · 4 comments
Closed

cookie的设置 #48

Jing2684 opened this issue Sep 30, 2019 · 4 comments

Comments

@Jing2684
Copy link

请问下,我通过你的demo测试发现我把原生cookie设置的相关代码去掉,在wkwebview的一个页面,网页设置了cookie,退出后,重新进入浏览器还是可以有cookie的,但是如果你的网页不是通过getReusedWebViewForHolder初始化的就没有这个cookie了,不是很理解,这个cookie同步真实起作用的哪个

@xiubojin
Copy link
Owner

xiubojin commented Oct 8, 2019

怎么设置的cookie,document.cookie吗?

@Jing2684
Copy link
Author

Jing2684 commented Oct 8, 2019

是的,document.cookie = cookieKey + i + "=" + Math.random();

@xiubojin
Copy link
Owner

是的,document.cookie = cookieKey + i + "=" + Math.random();

document.cookie设置的cookie不会同步到cookie存储域,所以新创建的WebView是没有的,根据你的情况,通过getReusedWebViewForHolder拿到的WebView始终都是那一个WebView,因为第一次用的时候已经设置过cookie了,所以下次复用的时候还有。

@Jing2684
Copy link
Author

我知道了,谢谢,共用一个wkprocesspool好像就可以了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants