1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
// jquery Cookie (function($){ $.cookie = function(key, value, options) { if(arguments.length > 1) { var o = $.extend({}, $.cookie.defaults, options); if (value === null || value === undefined) { value = ''; o.expires = -1; } if (o.expires.constructor != Date && o.expires > 0) { var today = new Date(); today.setDate(today.getDate() + o.expires); o.expires = today; } // Create the cookie string document.cookie = key + '=' + value + (o.expires != 0?'; expires=' + o.expires.toUTCString() : '') + (o.path? '; path=' + (o.path) : '') + (o.domain? '; domain=' + (o.domain) : '') + (o.secure? '; secure' : ''); } else { if(result = new RegExp(key+"=(.*?)(?:;|$)").exec(document.cookie)) return decodeURIComponent(result[1]); return false; } }; //' $.cookie = function(key, value, options) $.cookie.defaults = { expires: 365, path: '/' } // '$.cookie.defaults })(jQuery); // /jquery Cookie function cookieSave(num){ $.cookie("cookieTest", num, {expires:0, path:'/', secure:0}); } function check(){ alert($.cookie("cookieTest")); } |