How to use cookieManager to set a cookie visible in webview document.cookie?

529 views
Skip to first unread message

ryan agler

unread,
Jul 17, 2015, 5:15:50 PM7/17/15
to phon...@googlegroups.com
I currently have the following code in my cordova+crosswalk android app that successfully lets me get cookies that have come in via the webviews xmlhttprequest:

XWalkCookieManager cookieManager = new XWalkCookieManager();
String someCookie = cookieManager.getCookie("http://mydomain");

Where http://mydomain is the domain the javascript makes external calls to.

Obviously though in the webview, document.cookie does not return the above cookie, because the webview is in a file:// domain not http://mydomain.

So what I want to do is use cookieManager to set a cookie that will be synchronously viewable in the webview via document.cookie.  I have tried all of these:

cookieManager.setAcceptCookie(true);
cookieManager.setAcceptFileSchemeCookies(true);
cookieManager.setCookie("",someCookie);
cookieManager.setCookie("file://",someCookie);
cookieManager.setCookie("file:///",someCookie);
cookieManager.setCookie("file:///android_asset",someCookie);
cookieManager.setCookie("file:///android_asset/www",someCookie);

But none of those seem to work.  Is there a particular cookie domain i can use that will match the webview so it can see the cookie via document.cookie?

Kerri Shotts

unread,
Jul 18, 2015, 12:25:44 PM7/18/15
to phon...@googlegroups.com, ryan...@gmail.com
Looks like you are using Crosswalk -- you might ask them:  https://crosswalk-project.org/documentation/community.html
Reply all
Reply to author
Forward
0 new messages