Need Help Adding A Cookie

Need Help Adding A Cookie

Im using jquery with the cookie plugin and I have multiple image buttons that can hide/show multiple elements.

My question is how can I add a cookie to this code to remember whether each seperate element is opened or closed?

The code,
  1. $(document).ready(function() {

  2. // choose text for the show/hide link - can contain HTML (e.g. an image)
  3.     var showText='<div class="expanddown"></div>';
  4.     var hideText='<div class="expandup"></div>';

  5. // initialise the visibility check
  6.     var is_visible = false;

  7. // append show/hide links to the element directly preceding the element with a class of "toggle"
  8.     $('.toggle').prev().append('<a href="#" class="togglelink">'+hideText+'</a>');

  9. // capture clicks on the toggle links
  10.     $('a.togglelink').click(function() {

  11. // switch visibility
  12.     is_visible = !is_visible;

  13. // change the link depending on whether the element is shown or hidden
  14.     $(this).html( (!is_visible) ? hideText : showText);

  15. // toggle the display - uncomment the next line for a basic "accordion" style
  16. //$('.toggle').hide();$('a.toggleLink').html(showText);
  17.     $(this).parent().next('.toggle').slideToggle('fast');

  18. // return false so any link destination is not followed
  19. return false;
  20. });
  21. });
HTML,
  1. <a class="togglelink" href="#"></a>

  2. <div class="toggle">
  3. Content
  4. </div>