Q:

Android set a cookie using org.apache.http.legacy

I'm trying to set a cookie in a Http Request, but I can't figure out how to implement it:
    HttpGet getReq = new HttpGet("https://www.myexample.com");
    getReq.setHeader("mycookie", "customvalue123");
    HttpClient client = new DefaultHttpClient();
    HttpResponse response = client.execute(getReq);
    result = EntityUtils.toString(response.getEntity());
    Log.e("RESPONSE", "GET RESPONSE: " + result);

My library is specificly this: 
android {
    useLibrary 'org.apache.http.legacy'
}

When it comes to make get or post requests, to get responses, no problem for me, but sending a simple cookie seems to be a very weird matter (considering that nothing about org.apache.http.legacy is on the internet about cookies). Thanks!

A:

Ok I found out the problem.
I post it here so it can be useful to those who will encounter the same topic.
The right way to set a cookie using org.apache.http.legacy library is this:
HttpGet getReq = new HttpGet("https://www.myexample.com");
getReq.setHeader("Cookie", "mycookie = customvalue123; mycookie2 = custom2");
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(getReq);
result = EntityUtils.toString(response.getEntity());
Log.e("RESPONSE", "GET RESPONSE: " + result);

