title: Setting a cookie upon a button click, postback performs a redirect
body: <p>I have a click event, so when a button gets clicked I save the users drop down list selections to a cookie using the jquery cookie plugin:</p>
  
  <pre><code>$.cookie("mycookie", selection_values);
  </code></pre>
  
  <p>When the form submits, on the server-side, I do a redirect:</p>
  
  <pre><code>Response.Redirect("/some/url");
  </code></pre>
  
  <p>When I examine the cookie, it seems that sometimes the values are saved and some times they are not.</p>
  
  <p>Is it because the redirect goes to another page and therefore the cookie doesn't save consistently?  Is there a timing issue somewhere?</p>
  
  <p>My code at a high level:</p>
  
  <pre><code>$(document).ready(function() {
    $(".mybutton").click(function() {
  
      // loop through controls, save to a variable
  
      $.cookie("mycookie", cookievalues);
    }
  
  
  
    // cookie
    var cookieValue = $.cookie("mycookie");
    if (cookieValue &amp;&amp; cookieValue.length) {
  
         // split cookie values
         // loop through and pre-select drop down lists
    }
  
  });
  </code></pre>