It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Cookie não funciona Chrome

Cookie não funciona Chrome

Postby alugopejr on Tue Nov 01, 2011 10:23 am

Boa tarde galera, uso o seguinte código javascript para salvar cookies no meu site, nele tenho um menu que altera entre 4 css's diferentes, funciona perfeitamente no IE e Firefox, porém não funciona no chrome, eu mudo o estilo (CSS) do site, quando eu clico no menu e vou para outra página o estilo é mantido, porém no chrome volta ao estilo padrão, dentro da mesma página muda normal o estilo, porém no chrome ao mudar de página volta ao estilo padrão, se alguém puder me dar uma força eu agradeço, já pesqusei bastante na net mas não encontrei a solução.
Segue o código:

jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
// CAUTION: Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined
// in the packed version for some reason...
var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};
alugopejr
 
Posts: 1
Joined: Tue Nov 01, 2011 10:20 am

Who is online

Users browsing this forum: No registered users and 6 guests