Uncaught TypeError: Cannot read property ‘cookie’

0

So, I’ve got a page where i set a cookie with js-cookie script and following code. js.cookie-2.1 is loaded right before that script.

 Cookies.set('dir', '1');

No JS errors there. When i try to get the cookie value on a different page, it looks like cookie script is not loading. Using following code

 jQuery(document).ready(function(){
    var cookie = $.cookie('dir');
       if (cookie > 1) { 
          $(".thereiscookie").show(); 
          } else { 
          $(".testcookie").show(); 
          }
 });

And i’m getting this error “Uncaught TypeError: Cannot read property ‘cookie’ of undefined”. js-cookie script is also loaded right before the above code.

Link: Uncaught TypeError: Cannot read property ‘cookie’
Source: Stack Jquery

Share.

About Author

Leave A Reply