views:

420

answers:

2

I'm using the "jQuery Cookie Plugin" on my homepage but it doesn't work in only chrome. And I use only chrome too. help please

+1  A: 

You may find that using raw JavaScript rather than a plugin to achieve such a simple task will be faster and easier to manage cross-browsers.

The below code works in Chrome.

// Thanks to http://www.quirksmode.org/js/cookies.html for the below functions
function createCookie(name,value,days) {
    if (days) {
     var date = new Date();
     date.setTime(date.getTime()+(days*24*60*60*1000));
     var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
     var c = ca[i];
     while (c.charAt(0)==' ') c = c.substring(1,c.length);
     if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
jakeisonline
Was this answer helpful Shitic? Let me know if it's not what you needed and I'll adjust the answer for you.
jakeisonline