I have a problem with Androids HttpClient / HttpRequest that's really giving me headache. The program should login on a website (it's actually working and login is successful). After it's logged in, I want it to get another path of the site, but I don't know how to stay logged in for the next call. The site is using cookies and i tried four different examples that i found on stackoverflow, but nothing helped me. The code I have is:
HttpClient loginclient = new DefaultHttpClient();
HttpPost loginpost = new HttpPost("EXAMPLEURL");
//Parameters
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
nameValuePair.add(new BasicNameValuePair("cookieuser", "1"));
nameValuePair.add(new BasicNameValuePair("vb_login_username", "EXAMPLE"));
nameValuePair.add(new BasicNameValuePair("vb_login_password", "EXAMPLE"));
nameValuePair.add(new BasicNameValuePair("do", "login"));
nameValuePair.add(new BasicNameValuePair("submit", "anmelden"));
// Url Encoding the POST parameters
try {
loginpost.setEntity(new UrlEncodedFormEntity(nameValuePair));
}
// Making HTTP Request
try {
HttpResponse response = loginclient.execute(loginpost);
String responseString = new BasicResponseHandler().handleResponse(response);
System.out.println(responseString);
}
PS: I removed the catch statements to make the code more clear