CookieManager and CookieSyncManager not syncing cookies to webview in ICS (works on all previous API levels)


I'm acquireing cookies through my app and use them internally by making requests to http. Users can switch to webview any given time, in which case I sync/inject cookies to webView.

Code for synchronizing cookies to webview using CookieSyncManager:

CookieManager cm = CookieManager.getInstance();
cm.setCookie(domain, cookieName + "=" + cookieValue);

This works on all API levels except API 15+ (Android 4.0, Ice Cream Sandwich). The CookieManager API is not deprecated.

What is causing this problem and are there any workarounds?


You can try the Apache DefaultHttpClient to do this work for you, I don't think it been changed in Ice Cream Sandwich.

I found this sample, but there is lots more in here

I had the same problem recently which I found was my mistake. The problem was the way I set the domain (but it worked till API 15). Try to prefix the domain with the dot: "" instead of "".

I wasn't injecting cookie from the client, but i found ICS cookie weren't saving.

One work around is to use the local storage instead of cookies. You don't need a cookie sync manager. this works on ics and v2+ android.

In my case I didn't have a domain , so the above didn't seem relevant - I was using a local html file in the asset folder of the app.

this works on ics and v2 android



// java
WebSettings webSettings = myWebView.getSettings();
webSettings.setDomStorageEnabled(true);   // localStorage

// e.g., if your package is www.myapp.whatever;


// javascript

function createCookie(name,value,days,path) {

function readCookie(name) {
    return localStorage.getItem(name);

Here is your answer : In ICs, can`t get cookie

Its the domain which is causing the issue.

for all version after 15+ you have to you have to use **.** , instead of

Need Your Help

Unrecognized tag prefix or device filter 'sc' (in VS2012)

visual-studio-2012 sitecore tagprefix

I can't get Visual Studio 2012 to recognize the 'sc' tagPrefix.

MS Access connect to mysql backend automatically

mysql ms-access connector

I have an MS Access 2003 frontend and mySQL backend.