title: Maintaining cookies between Mechanize requests
body: <p>I'm trying to use the Ruby version of Mechanize to extract my employer's tickets from a ticket management system that we're moving away from that does not supply an API.</p>
  
  <p>Problem is, it seems Mechanize isn't keeping the cookies between the <code>post</code> call and the <code>get</code> call shown below:</p>
  
  <pre><code>require 'rubygems'
  require 'nokogiri'
  require 'mechanize'
  
  @agent = Mechanize.new
  
  page = @agent.post('http://&lt;url&gt;.com/user_session', {
                                              'authenticity_token' =&gt; '&lt;token&gt;',
                                              'user_session[login]' =&gt; '&lt;login&gt;',
                                              'user_session[password]' =&gt; '&lt;password&gt;',
                                              'user_session[remember_me]' =&gt; '0',
                                              'commit' =&gt; 'Login'
  })
  
  page = @agent.get 'http://&lt;url&gt;.com/&lt;organization&gt;/&lt;repo-name&gt;/tickets/1'
  puts page.title
  </code></pre>
  
  <p><code>user_session</code> is the URL to which the site's login page POSTs, and I've verified that this indeed logs me in. But the page that returns from the <code>get</code> call is the 'Oops, you're not logged in!' page.</p>
  
  <p>I've verified that <code>click</code>ing links on the page that returns from the <code>post</code> call works, but I can't actually get to where I need to go without JavaScript. And of course I've done this successfully on the browser with the same login.</p>
  
  <p>What am I doing wrong?</p>