How to set a Maginic popup with cookie

How to set a Maginic popup with cookie

In this post we talk about How to set Cookie In Megnific Popup

Step 1: Add this link under the head tag


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>

Step 2: Add this script below script tag


var check_cookie = $.cookie('bsw');
if (check_cookie == undefined) {
    $.cookie('bsw', 'yes', {expires: 1});
    $.magnificPopup.open({items: {src: '#popup-modal'},type: 'inline'}, 0);

    $(document).on('click', '.popup-modal-dismiss', function (e) {
      e.preventDefault();
      $.magnificPopup.close();
    });
}

If you have any questions please comment it 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top