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:'/'});
this??
$.cookie('query', '1'); //sets to 1... $.cookie('query', null); // delete it... $.cookie('query'); //gets the value.... if ($.cookie('query') == null){ //Check to see if a cookie with name of "query" exists $.cookie('query', '1'); //If not create a cookie "query" with a value of 1. } // If so nothing.
what more do you want??
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With