/* * Get Cookie * */getcookie:function (name) {var str = '; var cookies = Document.cookie; var arrcookie = Cookies.split (';'); for (Var i=0;i<arrcookie.length;i++) {var content = arrcookie[i].split (' = '); if (Content[0].replace (/^\s+|\s+$/g, "") = = Name.replace (/^\s+|\s+$/g, "")) {str = decodeURI (content[1]); Break }} return str; },/* * Write Cookie * expireshours How many days expire * */setcookie:function (Name,value,expireshours,path) {if (CPM). IsEmpty (path)) path = '/'; var cookiestring = name + "=" + encodeURI (value) + '; Path= ' +path; if (expireshours > 0) {var date = new Date (); Date.settime (Date.gettime () + expireshours * 86400); cookiestring = cookiestring + "; Expires= "+ date.togmtstring (); } document.cookie = cookiestring; },
Keep a record, you don't have to write again the next time you use it.
JavaScript settings Read Cookie