Magento 2.0.12

I have a widget that depends on mage/cookies, so I have:


], function($){

    // Some stuff


Everything works fine until I add an item to cart. When I do it Magento set the private_content_version cookie my widget stops working. It does nothing more, it doesn't pass for any function, it's as if there is nothing in the callback.

The widget returns to work if:

  • I remove the cookie
  • I remove "mage/cookies" dependency from my definition function
  • I disable the cache

None of the three things are fine to me. Any ideas?


Try to remove the mage/cookies and use like this sample.

<script type="text/javascript">
    ], function ($) {
        $(document).ready(function () {

            var check_cookie = $.cookie('foo'); // Get Cookie Value
            var date = new Date();
            var minutes = 60;
            date.setTime(date.getTime() + (minutes * 60 * 1000));
            $.cookie('foo', '', {path: '/', expires: -1}); // Expire Cookie
            $.cookie('foo', 'bar', {expires: date}); // Set Cookie Expiry Time
            $.cookie('foo', 'setvalue'); // Set Cookie Value
  • I didn't know there was also jquery cookie in Magento2. It works! Thanks so much
    – nuovecode
    May 16 '17 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.