I want to:
Note: I am using jQuery 1.4.2 and the jQuery cookie plugin.
Does anyone have any suggestions as to how I can do this?
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:'/'});