alexwc_
alexwc_

Reputation: 1603

Cookie + Zurb Reveal

Still realllly new to this stuff, so I hope my description of the issue is accurate.

I've just plugged in Zurb Reveal, and got it work on page load with

$(document).ready(function (){
    $('#myModal').reveal();
});

Now how do I get a cookie to function so that this only show once a day per user? I don't want to have this popup happening every time a user navigates to the home page.

Any help would be appreciated!

Upvotes: 2

Views: 910

Answers (1)

Sarcastron
Sarcastron

Reputation: 1527

I can't setup a dev environment

Since you are already using jQuery, you can get the jQuery Cookie plugin (https://github.com/carhartl/jquery-cookie). Then you could use code similar to this:

$(document).ready(function(){
    // if the cookie doesn't exist create it and show the modal
    if ( ! $.cookie('hereToday') ) {

        // create the cookie. Set it to expire in 1 day
        $.cookie('hereToday', true, { expires: 1 });

        //call the reveal modal
        $('#myModal').reveal();
    }
});

Upvotes: 5

Related Questions