title: JSOUP Automatically Login to a website
body: <p>I am trying to parse a website which requires login. From browser, when I do login at the login page(<a href="https://backoffice.holidayinsider.com/backoffice2/login" rel="nofollow noreferrer">https://backoffice.holidayinsider.com/backoffice2/login</a>), I am automatically redirected to <a href="https://backoffice.holidayinsider.com/backoffice2/login" rel="nofollow noreferrer">https://backoffice.holidayinsider.com/backoffice2/login</a>. </p>
  
  <p>So first of all I am trying to automate the login using Java. My approach is motivated by this <a href="https://stackoverflow.com/questions/37289037/jsoup-how-to-crawl-a-login-required-page-using-jsoup">stackoverflow response</a>. The code I am using is the following:</p>
  
  <pre><code>package Login;
  import org.jsoup.Connection;
  import org.jsoup.Jsoup;
  import org.jsoup.nodes.Document;
  import java.io.IOException;
  import java.util.Map;
  public class DoLogin {
      public static void main(String[] args)
      {
  
          try {
  
              Connection.Response loginForm = Jsoup.connect("https://backoffice.holidayinsider.com/backoffice2/login")
                  .method(Connection.Method.GET)
                  .execute();
  
              Connection.Response mainPage = Jsoup.connect("https://backoffice.holidayinsider.com/backoffice2")
                  .data("username", "myusername")
                  .data("password", "mypass")
                  .cookies(loginForm.cookies()).execute();
              System.out.println(mainPage.parse());
  
              Map&lt;String, String&gt; cookies = mainPage.cookies();
  
              Document evaluationPage = Jsoup.connect("https://backoffice.holidayinsider.com/backoffice2/")
                  .cookies(cookies)
                  .execute().parse();
              System.out.println(evaluationPage);
  
  
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>It seems the login is working as status code is 200. Now the problem is when I print mainPage, it seems it is still at login page. What can be the reason? Thank you in advance for any help or suggestion.</p>