如何在 android.webkit.WebView 之间共享缓存(包括 cookie)
我的应用程序在不同的屏幕上有几个不同的 WebView。我希望能够在一个屏幕上登录,并保存带有用户客户信息的 cookie。在另一个屏幕上,我希望他们能够保持登录状态以查看自定义定价、帐户信息等。这需要两个 WebView 共享相同的 cookie。有没有简单的方法可以做到这一点?或者甚至访问cookies?或者使用通用的 Web 缓存存储库?
My app has several different WebViews on different screens. On one screen I would like to be able to sign in, saving a cookie with the user's customer information. On another screen, I would like them to be able to remain signed in to view custom pricing, account info, etc. This requires the two WebViews to share the same cookie. Is there an easy way to do this? Or even access the cookies? Or use a common repository for web cache in general?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明这是一个愚蠢的问题。由于某种原因,我尝试扩展的应用程序未在 WebView 之间共享 cookie。我认为这是 Android SDK 的问题,而不是应用程序本身的问题。我用多个 WebView 编写了一个简单的示例应用程序,并清楚地看到它们默认共享 cookie。现在要弄清楚我正在开发的应用程序为何或如何设法避免在 WebView 之间共享 cookie。
It turns out this is kind of a silly problem. The app I'm trying to extend is not sharing cookies between WebViews for some reason. I assumed this was an issue with the Android SDK and not the app itself. I coded up a simple example app with multiple WebViews and saw clearly that they were sharing cookies by default. Now to figure out why or how the app I'm working on managed to circumvent sharing cookies between it WebViews.