Cookie expiration date not being set right?

Cookie expiration date not being set right?

Hello all, I need some quick help with one of my scripts. 

It's supposed to set the expiration date of all the cookies on my page for one year, but it's not working.

I know it's not working because Safari lets you see the expiration date for each cookie set on a page, and it didn't show it for the elements being set on my page.

I'm using jQuery for this, so heres my one script:

  1. var currentRotation=null;

  2. function checkOrientAndLocation(){
  3. if(currentRotation != window.orientation){
  4. setOrientation();
  5. }
  6. }

  7. function setOrientation(){
  8. switch(window.orientation){
  9. case 0:
  10. orient = 'portrait';
  11. break;
  12. case 90:
  13. orient = 'landscape';
  14. break;
  15. case -90:
  16. orient = 'landscape';
  17. break;
  18. }
  19. currentRotation = window.orientation;
  20. document.body.setAttribute("orient",orient);
  21. setTimeout(scrollTo,0,0,1);
  22. }

  23. $(window).unload(function() { // On page unload
  24.     $('.remember').each(function() { // Save each value to expire in a year
  25.         $.cookie(this.id, this.value, {expires: 365});
  26.     });
  27.     $('.draggable').each(function() { // Save draggable positions
  28.         var draggable = $(this);
  29.         $.cookie(this.id, draggable.css('top') + '_' + draggable.css('left'), {expires: 365});
  30.         $.cookie('disp' + this.id, draggable.css('display'), {expires: 365});
  31.     });
  32. });

  33. $(function() {
  34.   var val, pos, disp;
  35.   setInterval(checkOrientAndLocation,1000);
  36.   $('.remember').each(function() {
  37.         var val = $.cookie(this.id); // Retrieve value for this element
  38.         if (val) {
  39.             this.value = val;
  40.         }
  41.     }
  42.   );
  43.   $('.draggable').each(function() {
  44.         var pos = $.cookie(this.id); // Retrieve values for this element
  45.         if (pos) {
  46.             pos = pos.split('_');
  47.             $(this).css({position: 'absolute', top: pos[0], left: pos[1]});
  48.         }
  49.         var disp = $.cookie('disp' + this.id);
  50.         if (disp) {
  51.             this.style.display = disp;
  52.         }
  53.     }
  54.    ).touch({animate: false, sticky: false, dragx: true, dragy: true,
  55.         rotate: false, resort: false, scale: false
  56.   });
  57. });

There's also a file that sets the basic elements for the cookie, but the expiration date code should be in the file above. Help is very much appreciated.