1/** 2 * Cookie plugin 3 * Copyright (c) 2006 Klaus Hartl (stilbuero.de) 4 * Dual licensed under the MIT and GPL licenses: 5 * http://www.opensource.org/licenses/mit-license.php 6 * http://www.gnu.org/licenses/gpl.html 7 */ 8jQuery.cookie = function(name, value, options) { 9 if (typeof value != 'undefined') { // name and value given, set cookie 10 options = options || {}; 11 if (value === null) { 12 value = ''; 13 options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed 14 options.expires = -1; 15 } 16 var expires = ''; 17 if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { 18 var date; 19 if (typeof options.expires == 'number') { 20 date = new Date(); 21 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); 22 } else { 23 date = options.expires; 24 } 25 expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE 26 } 27 // NOTE Needed to parenthesize options.path and options.domain 28 // in the following expressions, otherwise they evaluate to undefined 29 // in the packed version for some reason... 30 var path = options.path ? '; path=' + (options.path) : ''; 31 var domain = options.domain ? '; domain=' + (options.domain) : ''; 32 var secure = options.secure ? '; secure' : ''; 33 document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); 34 } else { // only name given, get cookie 35 var cookieValue = null; 36 if (document.cookie && document.cookie != '') { 37 var cookies = document.cookie.split(';'); 38 for (var i = 0; i < cookies.length; i++) { 39 var cookie = jQuery.trim(cookies[i]); 40 // Does this cookie string begin with the name we want? 41 if (cookie.substring(0, name.length + 1) == (name + '=')) { 42 cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); 43 break; 44 } 45 } 46 } 47 return cookieValue; 48 } 49};
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.