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/
Asked
Active
Viewed 3,556 times
1 Answers
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.
-
2Hehe, clearly the top guy qualified to answer the question. :D – st0le Jun 01 '12 at 08:24
-
Brilliant answer. How did I miss that? – Kashif Nazar Feb 15 '14 at 08:40
-
Note, tho, that PersistentCookieStore is misspelled in the code above. :-) My copy and paste failed me for 5 full minutes. – ZaBlanc Mar 13 '14 at 17:03