Magento – Magento set cookie popup

cookiemagento-1.9popupsession

This is my popup it show first time click only

How to achieve this?

<a href="#downloadme" class="fancyBoxLink">Value</a>
<div style="display:none">
    <div id="downloadme">
    <h1>Please fill following information to download files</h1>
        <form action="<?php echo $this->getUrl('downloadenquire/index/downloadme') ?>" method="post" id="download">
            <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
                <input type="text" name="name" placeholder="Name" required="true" class="input-text required-entry validate-alpha" />
                <input type="text" name="email" placeholder="Email" required="true" class="input-text required-entry validate-email"/>
                <input type="text" name="mobile" placeholder="Mobile" required="true" class="input-text required-entry validate-number"/>
            <input type="submit" value="Submit" id="submit-download" />
        </form>
    </div>
</div>



<script type="text/javascript">
jQuery(document).ready(function($) {
    $("a.fancyBoxLink").fancybox({
        'href'   : '#downloadme',
        'titleShow'  : false,
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic',
        'openEffect'    : 'elastic',
        'closeEffect'   : 'elastic',
        'maxWidth'  : 800,
        'maxHeight' : 600,
        'fitToView' : false,
        'width'     : '35%',
        'height'    : '38%',
        'autoSize'  : false,
        'closeClick'    : false
    }); });
</script>

<script type="text/javascript">
    //< ![CDATA[
        var customForm = new VarienForm('download');
    //]]>
</script>

Best Answer

I save the cookie for popup with this function

_setCookie: function () {
        var expDate = new Date();

        expDate.setTime(expDate.getTime() + 3650000 * 60 * 1000);
        $.cookie('popup_cookie', 1, {
            expires: expDate
        });
    }

With if statement checking if cookie exsists and if exsists I don't show popup. I call this function when closed:function() runs or when success:function() runs I don't know you need it exactly or not, hope it ll help you.

Related Topic