Set a jQuery cookie to show popup only once Set a jQuery cookie to show popup only once jquery jquery

Set a jQuery cookie to show popup only once


Something of this kind might be of help:

$(document).ready(function(){   if ($.cookie('test_status') != '1') {    //show popup here    $.cookie('test_status', '1', { expires: 60}); }   });


First include the jquery library.

After include the below script for cookies in jquery.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>

Now put the below code into the footer :

$(document).ready(function() {       // initially popup is hidden:        $('#stay-in-toch.popup-outer').hide();        // Check for the "whenToShowDialog" cookie, if not found then show the dialog and save the cookie.        // The cookie will expire and every 2 days and the dialog will show again.        if ($.cookie('whenToShowDialog') == null) {            // Create expiring cookie, 2 days from now:            $.cookie('whenToShowDialog', 'yes', { expires: 2, path: '/' });            // Show dialog             $('#stay-in-toch.popup-outer').show();               }    });


You can try this

$(document).ready(function() {      if ($.cookie('test_status')) {        return;    }    //Rest of your code here});