...

View Full Version : Cookie expiration date not being set right?



pxlcreations
06-21-2010, 06:34 PM
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:


var currentRotation=null;

function checkOrientAndLocation(){
if(currentRotation != window.orientation){
setOrientation();
}
}

function setOrientation(){
switch(window.orientation){
case 0:
orient = 'portrait';
break;
case 90:
orient = 'landscape';
break;
case -90:
orient = 'landscape';
break;
}
currentRotation = window.orientation;
document.body.setAttribute("orient",orient);
setTimeout(scrollTo,0,0,1);
}

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

$(function() {
var val, pos, disp;
setInterval(checkOrientAndLocation,1000);
$('.remember').each(function() {
var val = $.cookie(this.id); // Retrieve value for this element
if (val) {
this.value = val;
}
}
);
$('.draggable').each(function() {
var pos = $.cookie(this.id); // Retrieve values for this element
if (pos) {
pos = pos.split('_');
$(this).css({position: 'absolute', top: pos[0], left: pos[1]});
}
var disp = $.cookie('disp' + this.id);
if (disp) {
this.style.display = disp;
}
}
).touch({animate: false, sticky: false, dragx: true, dragy: true,
rotate: false, resort: false, scale: false
});
});

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.

pxlcreations
06-22-2010, 02:15 AM
Bump.

gizmo1650
06-22-2010, 03:21 AM
browsers limit the lifetime of cookies, one year might be over the limit

pxlcreations
06-22-2010, 03:25 AM
Well I'm working in safari exclusively, but I've had cookies set for longer than a year and it usually shows the expiration date it in if you go to Prefs>Advanced>Show Cookies

Philip M
06-22-2010, 07:25 AM
browsers limit the lifetime of cookies, one year might be over the limit

Nonsense. :(

pxlcreations
06-22-2010, 11:54 AM
Nonsense. :(

Agreed, so any ideas what it might be?

Philip M
06-22-2010, 12:29 PM
Agreed, so any ideas what it might be?

Nope. You would do best to post your question in the jQuery forum.

pxlcreations
06-22-2010, 12:30 PM
Ok, thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum