androidcookiesandroid-webviewandroid-cookiemanager

How should I test cookies for WebView Android?


I have a webview which loads the given URL (say google.com). I log in Google but after closing the WebView activity and restarting a new one, I assumed I will have to log in again, but I didn't. I have not yet set my Cookies, using CookieManager. I am assuming, WebView stores some cookies by default.

So my question is, how can I test that my webView.loadURL with given cookies works properly?


Solution

  • Check:

    @Override
    public void onPageFinished(WebView view, String url){
        String cookies = CookieManager.getInstance().getCookie(url);
        Log.d(TAG, "Eat a cookie:" + cookies);
    }
    

    Credits