Server does not recognize cookies from Android phone

I am trying to connect to drupal server. I have been able to do this in the past, but drupal developers now require me to add another cookie. The server does not register a cookie, which I am trying to send below. Can anyone understand why?

public static void maybeCreateHttpClient() { if (mHttpClient == null) { mHttpClient = new DefaultHttpClient(); final HttpParams params = mHttpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, REGISTRATION_TIMEOUT); HttpConnectionParams.setSoTimeout(params, REGISTRATION_TIMEOUT); ConnManagerParams.setTimeout(params, REGISTRATION_TIMEOUT); BasicCookieStore cookieStore = new BasicCookieStore(); ClientCookie cookie = new BasicClientCookie("aml", key); cookieStore.addCookie(cookie); localContext = new BasicHttpContext(); localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); } } 
+7
source share
2 answers

Turns out I didn't have to use cookie, cookstore or httpcontent. As far as I understand, they are mainly used for managed cookies coming from the server.

I managed to solve my problem by setting such a header

  String key = "whatever"; post.addHeader("Cookie", "aml=" + key); 

This can be used on httppost, httpget or httput.

It took me a few days for such a simple solution. I hope this helps someone else.

+5
source

Oh, well, if you are looking for why cookies were not added, you did not receive or added cookie storage from the http client. You should receive cookie storage from the client, add your cookies and fulfill your request.

-one
source

All Articles