Sharing Cookie between different ports : <p>I have an application1(C#) that is hosted on port:80 and application 2(nodejs) that is hosted on port:3030. Both are on localhost.</p>

<p><strong>The request workflow is as following:</strong> </p>

<ul>
<li>browsers sends request to application 1</li>
<li>application 1 sends back number of cookies</li>
<li>later on browser sends the request to application 2 </li>
<li>^ problem is on the last step, the cookies doesnt get included in the request.</li>
</ul>

<p><strong>Things I have tried/understood:</strong> </p>

<ul>
<li>I understand that this is a same-origin policy restriction and because of different port # the browser treats them as different domains.</li>
<li><p>In Application 1 (its using System.Web.HttpCookie) i have tried to set the domain to be port specific ("127.0.0.1:3030") but seems like the browser doesnt accept it or ignore it. </p>

<pre><code>//c# code
var testCookie1 = new HttpCookie("Test", "testValue");
testCookie1.Domain = "127.0.0.1:3030";
testCookie1.Path = "/";
testCookie1.Expires = DateTime.Now.AddDays(1);
Response.SetCookie(testCookie1);

var testCookie2 = new HttpCookie("Test2", "testValue2");
testCookie2.Domain = "127.0.0.1";
testCookie2.Path = "/";
testCookie2.Expires = DateTime.Now.AddDays(1);
Response.SetCookie(testCookie2);
</code></pre></li>
</ul>

<p><a href="https://i.stack.imgur.com/PsxQN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PsxQN.png" alt="Cookies that come back from server"></a>
<a href="https://i.stack.imgur.com/ZeY1d.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZeY1d.png" alt="Cookies that get stored in browser"></a></p>

<p>The server sends back a cookie with the port number attached to it but the browser seems like it ignores it.</p>

<p>and here is my ajax calls: </p>

<pre><code>   var request = $.ajax({
        url: 'http://127.0.0.1:3030/SomeTask',
        type: 'POST',
        crossDomain: true,
    });
</code></pre>
