title: set cookie in jquery for show/hide div
body: <p>I have a CSS menu in a div that is set with CSS: display:none; on page load.</p>
  
  <p>I have this html:</p>
  
  <pre><code>&lt;a class="show_menu"&gt;Show Menu&lt;/a&gt;
  &lt;a class="hide_menu" style="display:none;"&gt;Hide Menu&lt;/a&gt;
  
  &lt;div id="nav" style="display:none;"&gt;
  div content here
  &lt;/div
  </code></pre>
  
  <p>and this JQUERY:</p>
  
  <pre><code>&lt;script type = "text/javascript"&gt;
  $('.show_menu').click(function() {
     $('#nav').toggle();
     $("#page_cont").css("width", "80%");
     $(".hide_menu").css("display", "block");
     $(".show_menu").css("display", "none");
  });
  $('.hide_menu').click(function() {
     $('#nav').toggle();
     $("#page_cont").css("width", "100%");
     $(".hide_menu").css("display", "none");
     $(".show_menu").css("display", "block");
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>What would be the best way to see a cookie when the div is shown or hidden so when the user changes the page, if they had the menu open it would stay open on another page and if they close the menu it would close on all other pages until they open it again?</p>
  
  <p>EDIT: here is my new code</p>
  
  <pre><code>&lt;script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.3.1/jquery.cookie.min.js"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  var menu_state = $.cookie('mydomain_menuflag');
  alert(menu_state);
  if(menu_state !== "undefined" &amp;&amp; menu_state == "visible" ) $('#nav').show;
  &lt;/script&gt;
  
  &lt;div class="show_menu"&gt;&lt;a&gt;Show Menu&lt;/a&gt;&lt;/div&gt;
  &lt;div class="hide_menu" style="display:none;"&gt;&lt;a&gt;Hide Menu&lt;/a&gt;&lt;/div&gt;
  
  &lt;div id="nav" style="display:none;"&gt;
  &lt;li&gt;&lt;a href="/admin/index.php"&gt;Dashboard&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a&gt;Contacts&lt;/a&gt;
      &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;Companies&lt;/strong&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/admin/index.php?id=customer/addcustomer"&gt;Add Company&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/admin/index.php?id=customer/viewcustomer"&gt;View Company&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Contacts&lt;/strong&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/admin/index.php?id=contacts/addcontact"&gt;Add Contact&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/admin/index.php?id=contacts/viewcontact"&gt;View Contact&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Resellers&lt;/strong&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/admin/index.php?id=reseller/addreseller"&gt;Add Reseller&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/admin/index.php?id=reseller/viewreseller"&gt;View Reseller&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Salesman&lt;/strong&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/admin/index.php?id=salesman/addsalesman"&gt;Add Salesman&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="/admin/index.php?id=salesman/viewsalesman"&gt;View Salesman&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a&gt;Customer Info&lt;/a&gt;
      &lt;ul&gt;
      &lt;li&gt;&lt;a href="/admin/index.php?id=customer/commsone-phonelines"&gt;Comms One Phone Lines&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/li&gt;
  
  &lt;/div&gt;
  
  &lt;script type = "text/javascript"&gt;
  $('.show_menu').click(function() {
     $('#nav').toggle();
     $("#page_cont").css("width", "80%");
     $(".hide_menu").css("display", "block");
     $(".show_menu").css("display", "none");
     $.cookie('mydomain_menuflag', 'visible');
     var menu_state = $.cookie('mydomain_menuflag');
     alert(menu_state);
  });
  $('.hide_menu').click(function() {
     $('#nav').toggle();
     $("#page_cont").css("width", "100%");
     $(".hide_menu").css("display", "none");
     $(".show_menu").css("display", "block");
     $.cookie('mydomain_menuflag', 'hidden');
  });
  &lt;/script&gt;
  </code></pre>