1// Cookies: see http://www.netspade.com/articles/javascript/cookies.xml 2// and http://www.quirksmode.org/js/cookies.html 3 4// This is best-effort only, as we need the domain and path both to match exactly to delete 5// the cookie and this information is not available to Javascript or the server. 6// We don't have to exclude JSESSIONID as it's marked HttpOnly 7function clearAllCookies() { 8 var cookies = document.cookie.split(';'); 9 for (var i = 0; i < cookies.length; i++) { 10 eraseCookie(cookies[i].split('=')[0].trim(), '/'); 11 } 12} 13 14function getCookie(name) { 15 var match = (' ' + document.cookie).match(new RegExp(' ' + name + '=([^;]+)')); 16 var ret = match && match[1] || ''; 17 ret = unescape(ret); 18 ret = name === 'logintest' ? ret : ret.replace(/^"/, '').replace(/"$/, ''); 19 return ret; 20} 21 22function setCookieFull(name, value, expires, path, domain, secure) { 23 setRawCookieFull(name, escape( value ), expires, path, domain, secure); 24} 25 26function setRawCookieFull(name, value, expires, path, domain, secure) { 27 // we can only set persistent cookies with the user's permission 28 var allowPersistentCookies = (name === "allowPersistentCookies" && value === "1") 29 || (!(name === "allowPersistentCookies" && value === "0") && getCookie("allowPersistentCookies") === "1") 30 || (expires && expires < new Date()); 31 var expiry = allowPersistentCookies && expires ? expires.toGMTString() : "-1"; 32 33 var curCookie = name + "=" + value + 34 ((expires) ? "; expires=" + expiry : "") + 35 ((path) ? "; path=" + path : "") + 36 ((domain) ? "; domain=" + domain : "") + 37 ((secure) ? "; secure" : ""); 38 document.cookie = curCookie; 39} 40 41function setCookie(name, value, path) { 42 var expires = new Date(); 43 expires.setTime(expires.getTime() + (365 * 24 * 60 * 60 * 1000)); 44 path = path ? path : "/"; 45 setCookieFull(name, value, expires, path); 46} 47 48function eraseCookie(name, path, domain) { 49 var expires = new Date(); 50 expires.setTime( expires.getTime() - 1 ); 51 setCookieFull(name, "", expires, path, domain); 52}
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.