1//get a cookie with name 2function getCookie(name) { 3 var matches = document.cookie.match(new RegExp( 4 "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" 5 )); 6 return matches ? decodeURIComponent(matches[1]) : undefined; 7} 8 9 10// options (expires, path, domain, secure) 11function setCookie(name, value, options) { 12 options = options || {}; 13 14 var expires = options.expires; 15 16 if (typeof expires == "number" && expires) { 17 var d = new Date(); 18 d.setTime(d.getTime() + expires * 1000); 19 expires = options.expires = d; 20 } 21 if (expires && expires.toUTCString) { 22 options.expires = expires.toUTCString(); 23 } 24 25 value = encodeURIComponent(value); 26 27 var updatedCookie = name + "=" + value; 28 29 for(var propName in options) { 30 updatedCookie += "; " + propName; 31 var propValue = options[propName]; 32 if (propValue !== true) { 33 updatedCookie += "=" + propValue; 34 } 35 } 36 37 document.cookie = updatedCookie; 38} 39 40function deleteCookie(name) { 41 setCookie(name, "", { expires: -1 }) 42}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.