首页 > 解决方案 > Webview cookie 未更新

问题描述

Android Webview 加载了一个 API,首先,服务器发送未经身份验证的临时“FP”(cookie 名称)cookie 作为响应,在随后的调用中,服务器发送此“FP”cookie 的经过身份验证的新值,问题是这个新的经过身份验证的 cookie 永远不会在 android 中更新,它在 iOS 平台上运行良好,在桌面上也运行良好。

每次加载新 URL 时,我都会打印 cookie:

 override fun onPageFinished(view: WebView?, url: String?) {
                super.onPageFinished(view, url)
                val cookies3 = CookieManager.getInstance().getCookie(url)
                Log.d("Cookie", cookies3)
            }

但我没有看到任何新更新的 cookie。

这也是我的 Webview 设置:

ssoWebView.settings.javaScriptEnabled = true
    cookieManager.setAcceptCookie(true)
    cookieManager.setAcceptThirdPartyCookies(webView, true)

问题是这个新的经过身份验证的 cookie 永远不会在 android 中更新,它在 iOS 平台上运行良好,在桌面上也运行良好。

标签: androidwebview

解决方案


推荐阅读