Clinton Green Clinton Green - 1 month ago 12
jQuery Question

js-cookie: How to use cookies in an if statement

I am using the js-cookie plugin and I want to know how to use it in an if statement. In my scenario I want to show a popup if the Cookie does not exist.

Cookie

Cookies.set('adModalOpen', 'true', { expires: 8/24 });


If Statement

if ( !Cookies.get('adModalOpen') === 'true' ) {
// show popup
}


I've tried a using
=== Null
but that didn't work either.

Answer

just

if(!Cookies.get('adModalOpen')) {
 //show pop 
}