0

I'm trying to add cookies using c#, everything works good for me. But I need to make it visible on all pages. So please let me know where I need to add: ;path=/ in my code. here is my code:

<script>
  function banner() {
    $("#bannercookies").removeClass("open");
  }
  $(document).ready(function () {
    if ($.cookie("popup_1_2") == null) {
      $("#bannercookies").addClass("open");
      $.cookie("popup_1_2", "2");
    }
  });
</script>

<div id="bannercookies" class="banner-cookies">
  This website uses cookies to ensure you get the best experience on our
  website.
  <a href="PrivacyPolicy.html#section11" class="link-underlined white"
    >Cookies Policy</a
  >
  <button class="gotitbtn" onclick="banner();">GOT IT</button>
</div>
Maxim Mazurok
  • 3,856
  • 2
  • 22
  • 37
Shweta
  • 1

1 Answers1

0

$.cookie("popup_1_2", "2", { path: "/" }) should do what you want

$.cookie("test", 1, {
   expires : 10,           // Expires in 10 days

   path    : '/',          // The value of the path attribute of the cookie
                           // (Default: path of page that created the cookie).

   domain  : 'jquery.com', // The value of the domain attribute of the cookie
                           // (Default: domain of page that created the cookie).

   secure  : true          // If set to true the secure attribute of the cookie
                           // will be set and the cookie transmission will
                           // require a secure protocol (defaults to false).
});

from https://stackoverflow.com/a/1458728/4536543

Maxim Mazurok
  • 3,856
  • 2
  • 22
  • 37