title: Cookies are not getting set at the page load
body: <p>I  need to set some cookies when user visit for the very first time on page. So I clear the cookie of my browser and then try to load my project. After clearing cookie. Cookie is not being set at page load. I am working on MVC 5 with Razor</p>
  
  <p>This is my javascript code</p>
  
  <pre><code>  &lt;script src="~/Content/JavaScript/jquery.js"&gt;&lt;/script&gt;
          &lt;script src="~/Content/JavaScript/jqueryui/jquery-ui-1.10.4.custom.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          jQuery(document).ready(function () {
              getCookie("user_id");
              if (getCookie("user_id") == "") {
                  var user_id = guid();
                  setCookie("user_id", user_id, 365);
              }
  
              var currency_id = getCookie("currency_id")
              if (currency_id == "" || currency_id == null) {
                  setCookie("currency_id", "1", 365);
                  setCookie("currency_code", "INR", 365);
                  setCookie("currency_rate", "1", 365);
              }
              else {
                  ChangeCurrencyValue(currency_id)
              }
              ShowCart();
              ShowWishList();
  
          });
          &lt;/script&gt;
    &lt;script type="text/javascript"&gt;
       function setCookie(cname, cvalue, exdays) {
              var d = new Date();
              d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
              var expires = "expires=" + d.toUTCString();
              document.cookie = cname + "=" + cvalue + "; " + expires;
          }
          function getCookie(cname) {
              var name = cname + "=";
              var ca = document.cookie.split(';');
              for (var i = 0; i &lt; ca.length; i++) {
                  var c = ca[i];
                  while (c.charAt(0) == ' ') c = c.substring(1);
                  if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
              }
              return "";
          }
        function guid() {
              function s4() {
                  return Math.floor((1 + Math.random()) * 0x10000)
                    .toString(16)
                    .substring(1);
              }
              return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
                s4() + '-' + s4() + s4() + s4();
          }
          &lt;/script&gt;
  </code></pre>
  
  <p>I have already tried putting code in <code>&lt;head&gt;</code> block its not working</p>