0

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 }}
  • Your `cookie plugin js` is not loaded. You can check it in `console`. Possible duplicate of [cookie-is-not-a-function](http://stackoverflow.com/questions/4034190/cookie-is-not-a-function). – Rohan Kumar Jan 27 '14 at 05:05
  • looks like you have not included the [cookie plugin](https://github.com/carhartl/jquery-cookie) library.. add `` – Arun P Johny Jan 27 '14 at 05:06

1 Answers1

0

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);
}
});
Kishore
  • 73
  • 1
  • 6