/** * cookie操作类 */ var cookie = { set: function (name, value, iDay) { var oDate = new Date(); oDate.setDate(oDate.getDate() + iDay); document.cookie = name + '=' + value + ';expires=' + oDate+';Path=/'; }, get: function (name) { var arr = document.cookie.split('; '); for (var i = arr.length - 1; i >= 0; i--) { var arr2 = arr[i].split('='); if (arr2[0] === name) { return arr2[1]; } } return ''; }, del: function (name) { cookie.set(name, 1, -1); } }