Jquery.cookie = function (name, value, options) {
if (typeof value!= ' undefined ') {//name and value given, set cookie
options = Options {};
if (value = = null) {
Value = ';
Options.expires =-1;
}
var expires = ';
if (options.expires
&& (typeof options.expires = = ' number ' options.expires.toUTCString)}) {
var date;
if (typeof options.expires = = ' number ') {
Date = new Date ();
Date.settime (Date.gettime ()
+ (Options.expires * 24 * 60 * 60 * 1000));
} else {
date = Options.expires;
}
expires = '; Expires= ' + date.toutcstring (); Use expires attribute, Max-age isn't supported by IE
}
var path = Options.path? '; Path= ' + options.path: ';
var domain = Options.domain? '; Domain= ' + options.domain: ';
var secure = options.secure? '; Secure ': ';
Document.cookie = [name, ' = ', encodeURIComponent (value), expires,
Path, domain, secure].join (');
else {//only name given, get cookie
var cookievalue = null;
if (document.cookie && document.cookie!= ") {
var cookies = Document.cookie.split (';');
for (var i = 0; i < cookies.length; i++) {
var cookie = Jquery.trim (Cookies[i]);
if (cookie.substring (0, name.length + 1) = = (name + ' = ')) {
Cookievalue = decodeuricomponent (cookie
. substring (name.length + 1));
Break
}
}
}
return cookievalue;
}
};
Page reference:
$.cookie (name, value, options);
Parameter explanation:
--name Write the cookie key
--value writes the value of the cookie
--time limit for options storage