Title: Breaking JavaScript error when cookies/sessionStorage blocked
Last modified: October 15, 2020

---

# Breaking JavaScript error when cookies/sessionStorage blocked

 *  Resolved [weaselnerd](https://wordpress.org/support/users/weaselnerd/)
 * (@weaselnerd)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/breaking-javascript-error-when-cookies-sessionstorage-blocked/)
 * **JavaScript error (“Uncaught DOMException: The operation is insecure.” in Firefox)
   emitted from _cart\_widget.min.js_ if cookies/sessionStorage is blocked**
 * The issue can be reproduced by disabling all cookies in the browser settings (
   my tests were in Firefox). The error will display in the browser console and 
   had the effect of breaking the product variant selectors on my site. It is due
   to sessionStorage being blocked by the browser (or a content blocker).
 * I have temporarily worked around it by adding another try…catch statement around
   the first sessionStorage call in a modified copy of _cart\_widget.js_:
 *     ```
       jQuery(document).ready(function ($) {
   
           try {
               var empty_cart_hash = sessionStorage.getItem('woocommerce_cart_hash') == '';
           } catch(err) {
               var empty_cart_hash = '';
           }
           if ( empty_cart_hash || actions.is_lang_switched == 1 || actions.force_reset == 1 ) {
               wcml_reset_cart_fragments();
           }
       });
   
       function wcml_reset_cart_fragments(){
           try {
               jQuery(document).ready(function () {
                   jQuery(document.body).trigger('wc_fragment_refresh');
                   //backward compatibility for WC < 3.0
                   sessionStorage.removeItem('wc_fragments');
               });
           } catch(err){}
       }
       ```
   
 * I know disabling **all** cookies will break WooCommerce cart functionality completely,
   but this is just to reproduce the issue. At least one customer managed to have
   content blocking settings (I lack the specifics) that broke our product variation
   selector allowing them to choose the largest size item with no price change, 
   resulting in a drastically underpriced, yet placed order.
 * Hoping this can be fixed in a future plugin update.
 * Cheers,
    sean

Viewing 1 replies (of 1 total)

 *  [Izzi WPML](https://wordpress.org/support/users/izzih/)
 * (@izzih)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/breaking-javascript-error-when-cookies-sessionstorage-blocked/#post-13541437)
 * Thank you for the report Sean!
 * I will pass this along to our Dev team to test and hopefully resolve in future
   versions.
 * Best,
    Izzi

Viewing 1 replies (of 1 total)

The topic ‘Breaking JavaScript error when cookies/sessionStorage blocked’ is closed
to new replies.

 * ![](https://ps.w.org/woocommerce-multilingual/assets/icon-256x256.png?rev=2937122)
 * [WPML Multilingual & Multicurrency for WooCommerce](https://wordpress.org/plugins/woocommerce-multilingual/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-multilingual/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-multilingual/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-multilingual/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-multilingual/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-multilingual/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 1 reply
 * 2 participants
 * Last reply from: [Izzi WPML](https://wordpress.org/support/users/izzih/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/breaking-javascript-error-when-cookies-sessionstorage-blocked/#post-13541437)
 * Status: resolved