I am creating an app which needs to login to a website programmatically. I tried to use this code, but it doesn't log me in.
@Override
protected Boolean doInBackground(Void... arg0) {
try {
Connection.Response res = Jsoup.connect("http://omegastrike.co.uk/member.php?action=login")
.data("username", username, "password", password)
.followRedirects(true)
.method(Method.POST)
.execute();
Map<String, String> cookies = res.cookies();
Document doc2 = Jsoup.connect("http://omegastrike.co.uk/index.php")
.cookies(cookies)
.get();
System.out.println(doc2);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
Bonus question: How do I use this logged in connection for other functionalities in the app? Do I need to keep logging in?