Question

I've tried the various work arounds that have been mentioned in similar posts but I am still unable to make my modal window show only once per browsing session using the cookie. This is what my script looks like, if anyone can help me that would be perfect:

<script>  
$(document).ready(function() {
    if ($.cookie('modal_shown') == null) {
        $.cookie('modal_shown', 'yes', { expires: -1, path: '/' });
        setTimeout(function(){
          $("#modal").fadeIn(500);
        },7000);
    }
});
</script>
<script>
    $('#close').click(function() {
      $('#modal').hide();
    }
);
  </script>

And this is what my links look like:

<!--Modal-->
      <script type="text/javascript"  src="http://code.jquery.com/jquery-latest.min.js"></script>
      {{ "jquery-cookie.js" | asset_url | script_tag }}

No correct solution

OTHER TIPS

the expires option is not working. please try like this

$(document).ready(function () {
alert('I am ready');
if ($.cookie('modal_shown') == null) {
    $.cookie('modal_shown', 'yes');

    setTimeout(function(){
      $("#modal").fadeIn(500);
    },7000);
}
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top