How should I test cookies for WebView Android?

1.6k Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

Check:

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

Credits