Say you wanted to hide it for 7 days, it would look like this:
if(!$.cookie('hideTopBar')) $("#announcement_popup").fadeIn("slow"); $("a#closeit").click(function() { $.cookie('hideTopBar', 'true', { expires: 7 }); $("#announcement_popup").fadeOut("slow"); return false; });
Here we check whether the cookie is really set on any non-empty line, if it doesnβt die at all then. In the click handler, we set it to the same 'hideTopBar' cookie for any non-empty strying, 'true' can also be something else ... and using the expires parameter for 7 days.
expires takes several days (it can be a fraction !, for example, 1/24 for an hour), since this is the most common ... if you want a different expiration date, you can also calculate Date and pass it directly.
source share