2

How do I get cookies using loopj? I know how to set it, but I can`t get it. http://loopj.com/android-async-http/

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479

1 Answers1

8

Assuming you are creating and using your own PersistentCookieStore instance as follows:

CookieStore cookieStore = new PersistentCookieStore(this)
httpClient.setCookieStore(cookieStore);

Then you can simply use the cookieStore instance you created above.

Otherwise, with the latest android-async-http from github, you can do the following:

HttpContext httpContext = httpClient.getHttpContext();
CookieStore cookieStore = (CookieStore) httpContext.getAttribute(ClientContext.COOKIE_STORE);

Once you have the cookieStore instance, you can follow the docs to access the cookies.

tar
  • 1,538
  • 1
  • 20
  • 33
loopj
  • 1,599
  • 1
  • 15
  • 12