One user of my Webview based browser app reported an issue with embedding Google Calendar in an iframe. It looks like the iframe loaded by Android Webview (latest version from Google Play, tested with Android 6) can't read or set any cookies.
The issue is not present in Google Chrome on the same device. It seems to be related to Android Webview only.
I can reproduce the issue with following site.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
<a href=".asp">Cookies Management</a>
<br><br>
<iframe style="margin-top: 30px; border-width: 1px;" src=".asp" width="400" height="672" scrolling="yes"></iframe>
</body>
</html>
One user of my Webview based browser app reported an issue with embedding Google Calendar in an iframe. It looks like the iframe loaded by Android Webview (latest version from Google Play, tested with Android 6) can't read or set any cookies.
The issue is not present in Google Chrome on the same device. It seems to be related to Android Webview only.
I can reproduce the issue with following site.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
<a href="http://www.w3schools./js/js_cookies.asp">Cookies Management</a>
<br><br>
<iframe style="margin-top: 30px; border-width: 1px;" src="http://www.w3schools./js/js_cookies.asp" width="400" height="672" scrolling="yes"></iframe>
</body>
</html>
If you open the cookie site via link in the main frame you can set/read cookies by the buttons "Create Cookie..." or "Display All Cookies". In the iframe however displaying all cookies always returns an empty result. Even if you create a cookie in the iframe displaying all cookies then gets an empty result.
Are there any Webview settings affecting this behaviour?
Share Improve this question edited Jul 30, 2016 at 10:11 Krishna Kachhela 7931 gold badge7 silver badges24 bronze badges asked Jul 30, 2016 at 9:15 Alexey OzerovAlexey Ozerov 1,54815 silver badges26 bronze badges1 Answer
Reset to default 16I don't know why but the behaviour can be improved by enabling third party cookies like this:
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
CookieManager.getInstance().setAcceptThirdPartyCookies(webView,true);
After doing so the cookies are working in an iFrame as expected.