1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| function hasKey(name){ var strArray=document.cookie.split(";"); for(var i=0;i<strArray.length;i++){ var smallArray=strArray[i].split("="); if(smallArray[0].trim()==name){ return true; } } return false; }
function getValueByName(name){ var strArray=document.cookie.split(";"); for(var i=0;i<strArray.length;i++){ var smallArray=strArray[i].split("="); if(smallArray[0].trim()==name){ return smallArray[1]; } } }
function addCookie(name,value,time){ if(typeof time=="number"){ document.cookie=name+"="+value+";max-age"+time; }else{ document.cookie=name+"="+value+";expires"+time.toString(); } }
function removeCookie(name){ document.cookie=name+"=;max-age=-1"; }
|