1

I have a web application that serves only static contents - HTML, CSS and JavaScript. I have another application which is an ASP.NET Web API. Both applications are on same machine on different ports (for testing purpose and they could be on different machine or domain in production environment). When I browse the web application, it gets both cookie as well as form token of Anti CSRF on first ajax call from Web API. So I am setting the body token as header with setRequestHeader function of XMLHttpRequest. It doesn't seem there is any need to set the cookie token since cookies are restricted with HttpOnly Attribute for a security reason and as far as I know browser is responsible to send the cookie to whichever domain the cookie belongs to.

However, when I make consecutive ajax calls, instead of both these tokens being passed back to server, only the header token is being received by the server.

Currently the Web API is set with CORS restriction for the web application. But if the problem was related to cross origin then I guess, headers could not have been passed as well, correct me if I am mistaken.

So can anyone help me with this problem? I just want to be able to send cookies from one application to another without compromising in terms of security.

Akshay Raut
  • 413
  • 5
  • 19

1 Answers1

1

Take a look Cookies With My CORS and Set-Cookie in HTTP header is ignored with AngularJS

Ganesh
  • 126
  • 2
  • 12