title: Login to a site and then POST to a page in it
body: <p>I have to login to a page using three parameters, after that I have to POST two parameters to another page inside the site I've just logged in.</p>
  
  <p>So far I've got a cookie with this:</p>
  
  <pre><code>curl -c cookie.txt -d "username=username&amp;pwd=pwd&amp;domain=mydomain" http://myurl
  </code></pre>
  
  <p>...inside of the cookie I have a JSESSION id.
  I use the cookie as follows:</p>
  
  <pre><code>curl -b cookie.txt -d "par=value" http://myurlnumbertwo
  </code></pre>
  
  <p>Problems:</p>
  
  <ul>
  <li>even after a POST to the login url I get in the console the HTML code of the login page, does this mean that the login did not succeed? How can I find the error that caused this, maybe a log?</li>
  <li>after a successful login how do I remain in the login session and POST my parameters to the other page?</li>
  </ul>
  
  <p>EDIT:</p>
  
  <p>I finally got this working after stran's hint, follows the code.</p>
  
  <ul>
  <li>POST_DATA contains the exact encoded string that was posted, as in 'parameter1=value1&amp;parameter2=value2'</li>
  <li>ACTION_URL contains the full URL to which the form is posted, as in <a href="https://stackoverflow.com/users/login">https://stackoverflow.com/users/login</a></li>
  </ul>
  
  <p>First I did a</p>
  
  <pre><code>wget --save-cookie cookie.txt --post-data 'POST_DATA' ACTION_URL
  </code></pre>
  
  <p>to make the login and save the cookie, followed by a:</p>
  
  <pre><code>wget --load-cookie cookie.txt --post-data 'POST_DATA' ACTION_URL
  </code></pre>
  
  <p>to make the POST I needed, thank you again for the hint ^^</p>