I know that a similar question is posted here: Android Session cookies without using CookieManager However, I can not get it to work.
URL urlObj = new URL(urlPath);
conn = (HttpURLConnection) urlObj.openConnection();
if (urlPath.toLowerCase().startsWith("https:")) {
initializeHttpsConnection((HttpsURLConnection) conn);
}
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
// Send body data
os = conn.getOutputStream();
os.write(bodyData);
// Must flush and close to make sure all the data is sent.
os.flush();
os.close();
// Get response
in = conn.getInputStream();
System.out.println("Initial set of cookies:");
String cookie = conn.getRequestProperty("Cookie");
// Map> rp = conn.getRequestProperties(); if (cookie != null && cookie.length() > 0) { _cookie = cookie; Log.v("cookie2", _cookie); }
"cookie" is always null.
However, if I do include CookieManger (and run it with 2.3.3+) then cookie has the required value.