CookieManager not saving cookies

1.3k Views Asked by At

When I execute the following code:

CookieSyncManager.createInstance(activity); 
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);

webView.setWebViewClient(new WebViewClient() {
    @Override
    public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, 
                            String host, String realm) {
        Log.d(Utils.TAG, "There are cookies: " + cookieManager.hasCookies());
        handler.proceed("user","pass");
    }
}
webView.loadurl("https://...");

On JellyBean I get "There are cookies: true" while on Gingerbread I get "There are cookies: false"

It seems that on Gingerbread the cookies (one in this case) are not saved by the webView, thus the web page refuses to log me in because the cookie is not passed in the headers during authentication.

The same happens when using CookieSyncManager.

Also I don't know it it can be relevant but the code is executed by a Fragment using the Android Support Library.

Has anyone had this problem before?

Thanks.

0

There are 0 best solutions below