How to read cookies in a Phonegap-based Android app with Java

Just took me forever to get this straight, here is the trick on how to do it:

CookieSyncManager sym = CookieSyncManager.createInstance(appView.getContext());
CookieManager com = CookieManager.getInstance();
String cookie = com.getCookie("file:///android_asset");

if (cookie == null) Log.d("MainActivity", "Cookie is null");
	Log.d("MainActivity", "Cookie exists, value is:");
	Log.d("MainActivity", cookie);

Follow me on social media

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.