I would like to login into a website and keep the cookies. I have issues with the login part using Jsoup;
My code ;
Connection.Response loginForm = Jsoup.connect("URL" + "/login/").cookies(cookies).method(Connection.Method.GET).execute();
formData.put("username", "#######");
formData.put("pwd", "########");
formData.put("hidden","69");
formData.put("token", loginForm.parse().select("input#token").first().attr("value"));
Connection.Response homePage = Jsoup.connect("URL" + "/login/")
.referrer("URL" + "/login/")
.followRedirects(true)
.cookies(cookies)
.data(formData)
.method(Connection.Method.POST)
.execute();
cookies_2.putAll(homePage.cookies()); // save the cookies, this will be passed on to next request
If i go to the login page and use the developper tool there are ;
Edit 1;
The problem now is I get homepage of the website but without the section of login, I keep the "Connect or register" button.
I output the cookies_2 and it is the same that the cookies in the Chrome logs ;
Now, what I don't understand is why, I don't get loggin if I have the right cookies ?
Edit 2;
I chanded my code with the final solution and it work !
Thanks for your help !