js 操作cookies

如题:

 function setCookie(name, value, expires) {
        var x = name + "=" + escape(value);
        if (expires) {
            var d = new Date();
            d.setTime(d.getTime() + expires * 24 * 3600 * 1000);
            x += "; Expires=" + d.toGMTString();
        }
        document.cookie = x;
    }
    function getCookie(name) {
        var a = document.cookie.split("; ");
        name += "=";
        for (var i = 0; i < a.length; i++)
            if (a[i].indexOf(name) == 0)
                return unescape(a[i].substr(name.length));
        return "";
    }

你可能感兴趣的:(平时记录,javascript,cookie)