title: Jquery Menu remembering the state of the menu
body: <p>I am trying to get my menu system to read a cookie to it can remember the menu state. once remembered the menu would stayopen/close depending on the cookie.</p>
  
  <p>using alert in the javascript ive been able to read the cookie before and after clicks but sadly I cannot get the if statement correct in order to keep open/close the hidden html.</p>
  
  <p>any help much appreciated!</p>
  
  <p>code below:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;li class="primary"&gt;&lt;a href="user/me"&gt;My Profile&lt;/a&gt;&lt;/li&gt;
      &lt;div class="menu_content"&gt;
          &lt;ul&gt;
              &lt;li class="secondary"&gt;&lt;a href="&lt;?php print base_path() ?&gt;user/my-education"&gt;My Education History&lt;/a&gt;&lt;/li&gt;
              &lt;li class="secondary"&gt;&lt;a href="&lt;?php print base_path() ?&gt;user/my-achievements"&gt;My Achievements&lt;/a&gt;
                  &lt;ul&gt;
                      &lt;li&gt;&lt;a href="user/school"&gt;School&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="user/my-achievements/year1"&gt;Year 1&lt;/a&gt;&lt;/li&gt;
  
                  &lt;/ul&gt;
              &lt;/li&gt;
              &lt;li class="secondary"&gt;&lt;a href="user/my-details"&gt;My Account Details&lt;/a&gt;&lt;/li&gt;
              &lt;li class="secondary"&gt;&lt;a href="user/my-settings"&gt;My Account Settings&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
      &lt;li class="primary"&gt;&lt;a href="compare"&gt;Compare&lt;/a&gt;&lt;/li&gt;
      &lt;div class="menu_content"&gt;
          &lt;ul&gt;
              &lt;li class="secondary"&gt;&lt;a href="user/my-scores"&gt;My Scores&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Jquery</p>
  
  <pre><code>  var state = $.cookie("panelState");
  
          $("li.primary").click(function(){
  
          if($.cookie("panelState") == "expanded") {
              $(this).next().slideToggle('300');          
              $(this).removeClass("open");
              $(this).cookie("panelState", "collapsed");
              alert($.cookie("panelState"));
          } else if ($.cookie("panelState") == "collapsed") {
              $(this).next().slideToggle('300');
              $(this).addClass("open");
              $(this).cookie("panelState", "expanded");
              alert($.cookie("panelState"));
              }
          });
  </code></pre>