Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

jQuery - Set session with jQuery cookie plugin

0 votes
35 views
added Nov 16 in jQuery by LC Marshal Lieutenant (14,830 points)
// Use the following code with the jquery dependency of: 
// https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js

$(window).load(function() {
  var stoAd = $(".sto-ads-content > div[id^='div-gpt-ad']");
    if ($.cookie('noSto')) $('.sto-ads').hide();
    else {
        if(stoAd.length > 0){
          $('.sto-ads .slide-close').on('click', function(){
            $(this).parent().parent().removeClass('in');
          });

          if ($('body').hasClass('front')) {
            setTimeout(function(){
              $('.sto-ads').addClass('in');
            },300);
            console.log('front');
          }
          else {
            // do not show the slide in the beginning
            setTimeout(function(){
              $('.sto-ads').addClass('in');
            },300);
            console.log('not-front');
          }
        }
        $.cookie('noSto', true);  
    }
});

 

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...