title: curl - How to get a cookie from after login to send in a curl command?
body: <p>I want to get access to a json page that contains data. 
  Say, it's there under <code>http://example.com/home/apples.json</code>
  It's protected, so a login page is shown. 
  If I were to visit it manually I first go to <code>http://example.com/</code> There I get a login menu and after login as say user "test" with password "test" visiting <code>http://example.com/home/apples.json again</code> will show me the json data.</p>
  
  <p>If I do a </p>
  
  <pre><code>curl -u test:test http://example.com/home/apples.json -v
  </code></pre>
  
  <p>I end up at the login page. (Despite the authentication.)</p>
  
  <p>If I visit <a href="http://example.com/" rel="noreferrer">http://example.com/</a> and manually login I will get a cookie after login. Say this cookie is called ltoken and gets the value "dj8f". It will only show up after a successfull login. When I look it up via the browser and copy the cookie data and attach it to the curl command:</p>
  
  <pre><code>curl -b "ltoken="dj8f" http://example.com/home/apples.json -v
  </code></pre>
  
  <p>it will work.</p>
  
  <p>How can I get the cookie data from after login without doing it manually? 
  Is it possible via bash shell scripting means? If yes how? Alternatively how would it be done in a groovy script?</p>