jQuery ccookie

jQuery ccookie

I have a multiple alert system that display uniform alerts on all pages. I want when any of the alerts is closed, let it stay closed on all other pages on the website. I have tried so many thins but nothing works. It only. works when it is just one alert.

  1. // Alert session cookie starts here
  2. jg(document).ready(function () {
  3.     function closeBox() {
  4.         var closeBox = jg('.alert-box:visible').hide();
  5.         // - Notice how we pass a function and get an integer
  6.         jg.cookie('Alert-closed', true, {
  7.             path: '/'
  8.         });
  9.     }
  10.     console.log('Alert-closed');
  11.     // - Simply checks the alert box above
  12.     if (jg.cookie('Alert-closed')) {
  13.         console.log('Closing the alert box automatically...');
  14.         closeBox();
  15.     }
  16.     // Close the box on click
  17.     jg('.alert-switch').click(function () {
  18.         closeBox();
  19.     });
  20. });