Mar 26

Detectar si tienes las Cookies Habilitadas

Tag: Internet, Programación, Software, Tecnologiadeambulando @ 6:46 pm

Bueno! por fin!

Solución (c&p y modificado por mí ):

var Cookie =
{
read: function (name)
{
var arrCookies = document.cookie.split (’; ‘);
for (var i=0; i<arrCookies.length; i++)
{
var arrCookie = arrCookies[i].split (’=');

if (arrCookie[0] == name)
{
return decodeURIComponent (arrCookie[1]);
}
}
return false;
},

write: function (name, value, expires, path)
{
if (expires)
{
var date = new Date ();
date.setTime (date.getTime () + (((((expires * 24) * 60) * 60) * 1000)));
expires = ‘; expires=’ + date.toGMTString ();
}
else expires = ”;

if (!path) path = ‘/’;

document.cookie = name+’='+encodeURIComponent (value)+expires+’; path=’+path;
},

remove: function (name)
{
this.write (name, ”, -1);
}
}

Cookie.write(’cookiesEnabled’, 1);
var boolCookiesEnabled = Cookie.read(’cookiesEnabled’);
Cookie.remove(’cookiesEnabled’);
if (boolCookiesEnabled != 1)
{
window.location=’/content/noscript/’;
}

Deja un comentario