I’m having a problem with my android program and session cookies.
The Session is just not being held between calls, even thought i am using cookieStore.
The Webserver code is written in DJango, but the session is preserved when i use a C program with libcurl.
public class JSON {
...
DefaultHttpClient httpClient;
CookieStore cookieStore;
HttpContext httpContext;
HttpResponse response = null;
HttpPost httpPost = null;
HttpGet httpGet = null;
public JSON(Context context) {
f_context = context;
updateSettings();
HttpParams myParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(myParams, 10000);
HttpConnectionParams.setSoTimeout(myParams, 10000);
httpClient = new DefaultHttpClient(myParams);
cookieStore = new BasicCookieStore();
httpContext = new BasicHttpContext();
httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
}
...
public String JSONSendCmd(String methodName) {
String getUrl = URL + "json/" + methodName+'/';
httpGet = new HttpGet(getUrl);
try {
response = httpClient.execute(httpGet,httpContext);
} catch (Exception e) {
}
...
}
Try this: