title: wget does not set cookies
body: <p>Could someone tell me why my command does not work?</p>
  
  <p>Here is my form:</p>
  
  <pre><code>&lt;form id="query" method="POST" action="https://weblogin.mycompany.com/"
  enctype="application/x-www-form-urlencoded" autocomplete="off"&gt;
  &lt;table border="0" align="center"&gt;
  &lt;tr&gt;
  &lt;td class="fieldname"&gt;Username:&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="user" size="20" value="" class="inputfield" /&gt; &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td class="fieldname"&gt;Password:&lt;/td&gt;
  &lt;td&gt;&lt;input type="password" name="pass" class="inputfield" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td class="fieldname"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="submit" value="Log in &amp;raquo;" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;div id='notifyuser'&gt;&lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And here is my wget command:</p>
  
  <p>% wget --save-cookies /tmp/cookies.txt --post-data 'user=my_id&amp;pass=my_passwd' \ <a href="https://weblogin.mycompany.com/" rel="nofollow noreferrer">https://weblogin.mycompany.com/</a></p>
  
  <p>After I executed the wget command above, the cookie file is empty.</p>
  
  <pre><code>% cat /tmp/cookies.txt
  # HTTP cookie file.
  # Generated by Wget on 2013-07-02 16:23:39.
  # Edit at your own risk.
  </code></pre>
  
  <p>And the http response:</p>
  
  <pre><code>% wget --keep-session-cookies --save-cookies /tmp/wget03_cookies.txt --post-data 'user=my_id&amp;pass=my_passwd' **https://weblogin.mycompany.com/**
   --2013-07-03 09:52:06--  https://weblogin.mycompany.com/
   Resolving weblogin.mycompany.com... 1.1.1.1
   Connecting to weblogin.mycompany.com|1.1.1.1|:443... connected.
   HTTP request sent, awaiting response... 200 OK
   Length: 4477 (4.4K) [text/html]
   Saving to: `index.html.10'
  
   100%[===========================================================================&gt;] 4,477       --.-K/s   in 0s
  
   2013-07-03 09:52:06 (36.8 MB/s) - `index.html.10' saved [4477/4477]
  </code></pre>
  
  <p>What did I do wrong?</p>
  
  <hr>
  
  <p>I might find a solution at this thread: <a href="https://stackoverflow.com/questions/4272770/wget-with-authentication">wget with authentication</a></p>
  
  <p>The solution is like this:</p>
  
  <pre><code>#!/bin/sh
  
  # get the login page to get the hidden field data
  wget -a log.txt -O loginpage.html http://foobar/default.aspx
  hiddendata=`grep value &lt; loginpage.html | grep foobarhidden | tr '=' ' ' | awk '{print $9}' | sed s/\"//g`
  rm loginpage.html
  
  # login into the page and save the cookies
  postData=user=fakeuser'&amp;'pw=password'&amp;'foobarhidden=${hiddendata}
  wget -a log.txt -O /dev/null --post-data ${postData} --keep-session-cookies --save-cookies cookies.txt http://foobar/default.aspx
  
  # get the page your after
  wget -a log.txt -O results.html --load-cookies cookies.txt http://foobar/lister.aspx?id=42
  rm cookies.txt
  </code></pre>
  
  <p>What I don't understand is --
  What am I supposed to use to substitute 'foobarhidden' while generating hiddendata?</p>
  
  <p>I believe the following portion should give me the answer. But I dont know what exactly to do:</p>
  
  <pre><code>% grep value &lt; loginpage.html | grep hidden
  3:109:&lt;input type=hidden name=pubcookie_g_req value="b25lPWFsb2hhLmFrYW1haS5jb20mdHdvPWFsb2hhJnRocmVlPTEmZm91cj1hNWEmZml2ZT1HRVQmc2l4PWFsb2hhLmFrYW1haS5jb20mc2V2ZW49THc9PSZlaWdodD0mYWthX2ZyYWc9Jmhvc3RuYW1lPWFsb2hhLmFrYW1haS5jb20mbmluZT0xJmZpbGU9JnJlZmVyZXI9KG51bGwpJnNlc3NfcmU9MCZwcmVfc2Vzc190b2s9NjMzMzQ0OTI3JmZsYWc9MA=="&gt;
  4:110:&lt;input type=hidden name=post_stuff value=""&gt;
  5:111:&lt;input type=hidden name=relay_url value="https://weblogin.mycompany.com/PubCookie.reply"&gt;
  </code></pre>
  
  <p>Thanks!!</p>