Monday, August 19, 2013

jQuery set cookie for first visit

<script type="text/javascript">
    $(document).ready(function() {
        // check cookie
        var visited = $.cookie("visited")

        if (visited == null) {
            $('.newsletter_layer').show();
            $.cookie('visited', 'yes'); 
            alert($.cookie("visited"));         
        }

        // set cookie
        $.cookie('visited', 'yes', { expires: 1, path: '/' });
    });
</script>

No comments:

Post a Comment