1

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.

Francesco
  • 184
  • 2
  • 10
  • Did you solve your problem? I'm facing exactly the same now – Pedro Teran Oct 07 '13 at 14:45
  • 1
    @Pedro I solved the issue after some experiments, but I forgot to post the solution and now I'm not sure how I fixed it. After the line "CookieManager cookieManager = ..." add "CookieHandler.setDefault(cookieManager);". Let me now if it helps – Francesco Oct 08 '13 at 18:50
  • sorry but cookieHandler only acepts cookie type objects. so maybe you have something on the middle – Pedro Teran Oct 10 '13 at 14:03

0 Answers0