title: Persistent Cookie store using okhttp 2 on Android
body: <p>In my Android app, I am trying to switch from <code>android-async-http</code> to <code>okhttp</code> which supports async networking sind version 2.0. While the former ships with an implementation of a <a href="http://loopj.com/android-async-http/doc/com/loopj/android/http/PersistentCookieStore.html" rel="nofollow noreferrer">persistent cookie storage</a>, I don't know how to implement something like this for <code>okhttp</code>.</p>
  
  <p>In my app I have a login routine during which a <code>get</code> request is sent that, if successful, should set a cookie. This cookie should be appended to all subsequent network requests and should survive application restarts.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/18894540/using-retrofit-with-cookie-persistence">the following answer</a> on SO, indicating that the following piece of code, if executed somewhere in the app, activates persistent cookie management and <code>okhttp</code> would use it:</p>
  
  <pre><code>CookieManager cookieManager = new CookieManager();
  cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
  CookieHandler.setDefault(cookieManager);
  </code></pre>
  
  <p>However, for me it does not work. Is the <code>CookieManager</code> the right way to go? How could I monitor which cookies were set and stored to further debug the issue?</p>