Is there a specific library for Android session management? I need to manage my sessions in a normal Android app. not in WebView
. I can set the session from my post method. But when I send another request that session is lost. Can someone help me with this matter?
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("My url");
HttpResponse response = httpClient.execute(httppost);
List<Cookie> cookies = httpClient.getCookieStore().getCookies();
if (cookies.isEmpty()) {
System.out.println("None");
} else {
for (int i = 0; i < cookies.size(); i++) {
System.out.println("- " + cookies.get(i).toString());
}
}
When I try to access the same host that session is lost:
HttpGet httpGet = new HttpGet("my url 2");
HttpResponse response = httpClient.execute(httpGet);
I get the login page response body.