0

This doesn't seem to work in the IE Explorer ( Tools - Internet Options - Settings - View files) If you didn't know already, it is the cache explorer. Now my question is "What is wrong with this?"- It does not write to it. This is the code. Feel free to improve it.

function writeCookie(name,value,days) {
    var date, expires;
    if (days) {
        date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        expires = "; expires=" + date.toGMTString();
    }else{
        expires = "";
    }
    document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
    var i, c, ca, nameEQ = name + "=";
    ca = document.cookie.split(';');
    for(i=0;i < ca.length;i++) {
        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 '';
}
var sId = 's';
writeCookie('sessionId', sId, 3);
var sId = readCookie('sessionId');
document.write(sID);
Suhaib Janjua
  • 3,452
  • 14
  • 56
  • 72

0 Answers0