if($.cookie('query') === null) {
$.cookie('query', '1', {expires:7, path:'/'});
}
Alternatively, you could write a wrapper function for this:
jQuery.lazyCookie = function() {
if(jQuery.cookie(arguments[0]) !== null) return;
jQuery.cookie.apply(this, arguments);
};
Then you'd only need to write this in your client code:
$.lazyCookie('query', '1', {expires:7, path:'/'});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…