I use the Volley library for performing my app's requests. Now I really need to perform some operations following this order:
CookieManager
Strangely enough, the documentation is either out of date or outright incorrect, it seems that the CookieManager
will save session cookies with no problems at all. (Here's the bug report)
This snippet works for me:
private void syncCookie(String domain, Cookie sessionCookie) {
CookieSyncManager.createInstance(this);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeSessionCookie();
String cookieString = sessionCookie.getName() + "=" + sessionCookie.getValue() + "; domain=" + sessionCookie.getDomain();
cookieManager.setCookie(domain, cookieString);
CookieSyncManager.getInstance().sync();
}