Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Setting up cookies for a newsletter popup

I am trying to set up cookies that expire in 7 days after clicking the ‘x’ on the modal. I can’t figure out why it doesn’t want to save the cookie. Below is the code I am using. The site is goodbooks.io.

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"> </script>

<script>
    var cookieName = 'popupClosed';

    if(typeof Cookies.get(cookieName) !== 'undefined') {
        $('.popup-wrapper, .preview-page, .popup-content-wrapper, .popup').remove();
    }

    $('.close-popup').on('click'), function(){
        Cookies.set(cookieName, 'value', { expires: 7});

    }
</script>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Change

$('.close-popup').on('click'), function(){}

to

$('.close-popup').on('click', function(){})

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading