korhan-Ö
11/1/2017 - 1:10 PM

Cookie Operations

function setCookie() {

var now = new Date();
now.setTime(now.getTime() + 24 * 3600 * 1000);
document.cookie = "lightboxcookie=lightboxseen; expires=" + now.toUTCString() + "; path=/";

//document.cookie="lightboxcookie=lightboxseen; expires=Thu, 18 Dec 2020 12:00:00 UTC";
}

function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";

}

function checkCookie() {
 var thecookie=getCookie("lightboxcookie");
    if (thecookie == "") {
console.log('cookie not setted');
            <!--Show Lightbox-->
            jQuery.noConflict()(function ($) { 



                $(document).ready(function() { 
                                        $(".test").fancybox({
 maxWidth    : 800,
            type : 'iframe',
        'overlayShow' : true,
            maxWidth    : 800,
            maxHeight   : 600,
            fitToView   : false,
            width       : '70%',
            height      : '70%',
            autoSize    : false,
            closeClick  : false,
            openEffect  : 'none',
            closeEffect : 'none',


onClosed: function() {
                                        setCookie();
                                        },
                            helpers : {
                                                       overlay : {
                                                          closeClick: false,
                                                          css : {
                                                         'background' : 'rgba(0, 45, 92, 0.80)'
                                                          }
                                                       }
                                                    }});
                    $(".test").eq(0).trigger('click');

                });
            });
    }else {
  console.log('cookie setted before');
}
}