I am trying to get local cookies (file://) to work on android 3.1+
within ChildBrowser. I found a blog response talking about this
specific issue and how to remedy it with Cookie Manager. I can’t
figure out where in the plugin to put the code. Has anyone
successfully implemented this?
Comment Below from http://code.google.com/p/android/issues/detail?id=3739
Comment 16 by edtechk…@gmail.com, Feb 1, 2012
I got this thing working, for Android 2.2, javascript’s
document.cookie works fine, just make sure that in your
Webview…javascript is enabled like so:
yourWebViewVariable.getSettings().setJavaScriptEnabled(true);
for Android 3.1 just add this to your java file onLoadInit:
CookieManager.setAcceptFileSchemeCookies(true); //This is the line that specifically makes it work so the other lines is optional
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.acceptCookie();
For those interested, I figured it out. It is not a Childbrowser issue at all. You have to make the parent Phonegap project accept local cookies and then Childbrowser will too.
To do so, You should have a file called youappname.java in your PhoneGap project, probably with this contents or similar:
Modify it to look like this example: