Need to set a cookie on a toggle view

Need to set a cookie on a toggle view

Hi.

I need to set a cookie on a toggle switch which I found in a tutorial:

http://designm.ag/tutorials/jquery-display-switch/

I want to use this with pagination and keep the state the user set instead of reset on each page.
I found a suggestion in the comments on the tutorial but that did not work.

Can I use the cookie plugin for Jquery for this? and how do i do it? Here is my toggle code:

  1. <script type="text/javascript">
    $(document).ready(function(){
     
        $("a.switch_thumb").toggle(function(){
          $(this).addClass("swap");
          $("ul.display").fadeOut("fast", function() {
              $(this).fadeIn("fast").addClass("thumb_view");
             });
          }, function () {
          $(this).removeClass("swap");
          $("ul.display").fadeOut("fast", function() {
              $(this).fadeIn("fast").removeClass("thumb_view");
            });
        });
          
    });
    </script>