1/** 2 * Sets a Cookie with the given name and value. 3 * 4 * name Name of the cookie 5 * value Value of the cookie 6 * [expires] Expiration date of the cookie (default: end of current session) 7 * [path] Path where the cookie is valid (default: path of calling document) 8 * [domain] Domain where the cookie is valid 9 * (default: domain of calling document) 10 * [secure] Boolean value indicating if the cookie transmission requires a 11 * secure transmission 12 */ 13function setCookie(name, value, expiredays, path, domain, secure) 14{ 15 var ExpireDate = new Date (); 16 ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000)); 17 18 19 document.cookie= name + "=" + escape(value) + 20 ((ExpireDate) ? "; expires=" + ExpireDate.toGMTString() : "") + 21 ((path) ? "; path=" + path : "") + 22 ((domain) ? "; domain=" + domain : "") + 23 ((secure) ? "; secure" : ""); 24} 25 26/** 27 * Gets the value of the specified cookie. 28 * 29 * name Name of the desired cookie. 30 * 31 * Returns a string containing value of specified cookie, 32 * or null if cookie does not exist. 33 */ 34function getCookie(name) 35{ 36 var dc = document.cookie; 37 var prefix = name + "="; 38 var begin = dc.indexOf("; " + prefix); 39 if (begin == -1) 40 { 41 begin = dc.indexOf(prefix); 42 if (begin != 0) return null; 43 } 44 else 45 { 46 begin += 2; 47 } 48 var end = document.cookie.indexOf(";", begin); 49 if (end == -1) 50 { 51 end = dc.length; 52 } 53 return unescape(dc.substring(begin + prefix.length, end)); 54} 55 56/** 57 * Deletes the specified cookie. 58 * 59 * name name of the cookie 60 * [path] path of the cookie (must be same as path used to create cookie) 61 * [domain] domain of the cookie (must be same as domain used to create cookie) 62 */ 63function deleteCookie(name, path, domain) 64{ 65 if (getCookie(name)) 66 { 67 document.cookie = name + "=" + 68 ((path) ? "; path=" + path : "") + 69 ((domain) ? "; domain=" + domain : "") + 70 "; expires=Thu, 01-Jan-70 00:00:01 GMT"; 71 } 72}
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.