How to send cookies from account.domain.com to app.domain.com?

chouglesaud 6 Reputation points
2021-06-23T05:08:59.867+00:00

How to send cookies from account.domain.com to app.domain.com?

I am working on an authentication. I want to send cookies from account.domain.com to app.domain.com. The problem is, I can send cookies in the response header but the browser does not set the cookie. I can see in the network tab, cookies present in the response header.

cookie sent from account.domain.com

 var cookie = new HttpCookie("key", "value");

     cookie.Domain = "domain.com";
     cookie.HttpOnly = true;
     cookie.Secure = true;
     cookie.SameSite = System.Web.SameSiteMode.None;
     cookie.Path = "/";

 System.Web.HttpContext.Current.Response.Cookies.Add(cookie);

 return Ok();

on the client side, I use javascript(Axios) to send them.

I want to use these cookies across all sub domains i.e *.domain.com

await axios("/endpoint", {withCredentials: true});
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,598 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. AddWebSolution 171 Reputation points
    2021-06-23T07:01:03.857+00:00

    Request.Cookies are supposed to be cookies coming from client (browser) and Response.Cookies are cookies that will be send back to client (browser).
    Try to create like this :-write-cookies-from-subdomain-and-read-from-another-subdomain-without-changing-we

    1 person found this answer helpful.
    0 comments No comments

  2. Bruce (SqlWork.com) 74,531 Reputation points
    2021-06-23T14:46:41.853+00:00

    Are you using https? It is required for same site none.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.