2

I am using Loopj HTTP client to make my http requests to my server (http://loopj.com/android-async-http/). Requests are working perfectly. However, I am trying to implement sessions into the service. From the documentation, enabling cookies through saving data in a sharedpreference store is straight forward. The code goes like this:

    AsyncHttpClient client = new AsyncHttpClient();
    PersistentCookieStore myCookieStore = new PersistentCookieStore(getActivity());
    client.setCookieStore(myCookieStore);

The problem is that whenever I make a request to a script that requires a session, I get null responses as if the user does not have a session id. I am not sure how to debug where the exact problem is. How can I access myCookieStore to check if it is storing and sending the session id. I am trying logging myCookieStore.toString() but that does not give me the data inside.

Thanks.

Pacemaker
  • 1,117
  • 2
  • 17
  • 36

2 Answers2

0

Please do as this, this is works as my experience You have to convert it first to a List of Cookie, loop it and the store it in a String value

String cookieName = "";
String cookieValue = "";    
List<Cookie> cookies = myCookieStore.getCookies();
    for (Cookie c : cookies) {
        cookieName = c.getName().toString();
        cookieValue = c.getValue().toString();
    }
Gus Arik
  • 349
  • 2
  • 14
0

use client.setSSLSocketFactory()

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93