0

I have created a very simple ASP.Net MVC project with a single .cshtml file and 3 lines of Javascript as below -

<script type="text/javascript">
$(document).ready(function () {
    alert(document.cookie);
    document.cookie = "c1=1;expires=Thu, 01 Jan 2025 00:00:00 GMT;";
    alert(document.cookie);
});

When running the application via Visual studio, the above code displays cookies in Firefox but not in Google Chrome. Please advise on what could be the issue.

I have checked these links - 1 & 2

Please note that I do not want to change the hosts file on my local machine. Please advise on how can I get cookies working on my local machine on Chrome.

Anjan
  • 1
  • 1
  • 4

1 Answers1

0

Please see this quote from chromium project:

You can only set domain cookies for registry controlled domains, i.e. something ending in .com or so, but not IPs or intranet hostnames like localhost

More details can be found here: https://bugs.chromium.org/p/chromium/issues/detail?id=56211

Tomaleksp
  • 1
  • 2