function setCookie(name, value, ms){ var oDate=new Date(); oDate = new Date(oDate.getTime()+ms*1000); document.cookie=name+'='+encodeURIComponent(value)+';expires='+oDate; } function getCookie(name){ var arr=document.cookie.split('; '); var i=0; for(i=0;i<arr.length;i++){ //arr2->['username', 'abc'] var arr2=arr[i].split('='); if(arr2[0]==name){ var getC = decodeURIComponent(arr2[1]); return getC; } } return ''; } function removeCookie(name){ setCookie(name, '', -1); }