FacetWP – store post IDs into a cookie

mgibbs189

{{gist file=”test.js” lang=”javascript”}}
<script>
(function($) {
$(document).on(‘facetwp-loaded’, function() {
var cookie_data = JSON.stringify(FWP.settings.post_ids);
setCookie(“fwp_posts”, cookie_data, 7);
});
})(jQuery);

function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = “expires=”+d.toUTCString();
document.cookie = cname + “=” + cvalue + “; ” + expires;
}
</script>
{{/gist}}