cookie不加载wkwebview

发布于 2025-01-18 06:41:50 字数 373 浏览 3 评论 0原文

我目前正在开发一个通过 .evaluateJavaScript() 使用 js 插件的 Web 视图。 js 脚本将读取 cookie 并将其与请求一起发送到与帐户身份验证的 Web 视图的 url 不同的 url。我在 URLSession.shared.configuration.httpCookieStorage 中有这个 cookie,并使用默认的 init() 初始化了 webView,而不传递任何参数。然而,注入js后,所需的cookie不会出现在网页的存储中。我尝试执行 webView.configuration.websiteDataStore.httpCookieStore.getAllCookies() 的输出,结果显示特定的 cookie 在那里。因此我对此感到困惑。任何人都可以帮助我,我将不胜感激。

I'm currently working on a web view that takes a js plugin via .evaluateJavaScript(). The js script will read a cookie and send it along with requests to a url that is different from the url of the web view for account authentication. I have this cookie in the URLSession.shared.configuration.httpCookieStorage, and initialized the webView with the default init() without passing any parameters. However, upon injecting the js, the required cookies does not appear in the webpage's storage. I tried to do an output of the webView.configuration.websiteDataStore.httpCookieStore.getAllCookies(), and the result shows the specific cookie is there. Hence I'm confused about it. Anyone could help me with that would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文