I am not getting how to store and get back cookies and checked with example programs also in this code I am trying to login with a url with username and pass credentials after that getting redirected to new page. I am trying to get the HTml content of the redirected page. But I need to pass the cookie to jsoup inorder to get the HTml content of the redirected page. I dont to store and get back cookies. Plz help me with code how to store and get back the cookies and pass it to the jsoup.
protected Object doInBackground(Object... params) {
try {
old URL--->URL url = new URL(UrlLink);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("POST");
List<NameValuePair> login = new ArrayList<NameValuePair>();
login.add(new BasicNameValuePair("login", "xxxxx"));
login.add(new BasicNameValuePair("password", "yyyyyy"));
login.add(new BasicNameValuePair("Login", "Login"));
login.clear();
int responseCode = urlConnection.getResponseCode();
System.out.println(responseCode);
urlConnection.connect();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
New Url---> URL newURL = urlConnection.getURL();
String urlNew= newURL.toString();
Returns--> doc=Jsoup.connect(res).data("login", "xxxxxxx")
.data("password", "ramesh88").get();
Login page Elements docEle = doc.select("#header a");
HTML Log.v("Document", docEle.toString() );
}
catch (Exception e) {
Log.v("Error", e.toString());
}