title: Sharing a cookie between two websites on the same domain
body: <p>Here's the situation:</p>
  
  <ul>
  <li>Website A, ASP.NET MVC 4 web application. Domain: <a href="http://a.example.com" rel="noreferrer">http://a.example.com</a></li>
  <li>Website B, ASP.NET MVC 4 web applicaiton. Domain: <a href="http://b.example.com" rel="noreferrer">http://b.example.com</a></li>
  </ul>
  
  <p>I'm trying to share a cookie (forms authentication) between the websites.</p>
  
  <p>I'm not using Forms Authentication per-se. I'm using the built-in methods (Encrypt, Decrypt, etc), but I'm setting my own custom cookie.</p>
  
  <p>When I set the cookie on one of the websites, the other ones sees the cookie, but can't decrypt it. The error is the generic "Error occurred during a cryptographic operation".</p>
  
  <p>What I've ensured:</p>
  
  <ol>
  <li>The cookie has the domain set to "example.com" (which means subdomains can access. Proof is the other website can "see" the cookie).</li>
  <li>Both websites share the same machine key. The web.config for both has the same value for the decryptionKey and validationKey.</li>
  <li>The forms authentication ticket version and cookie name are the same across both websites.</li>
  <li>The path is set to "/". </li>
  </ol>
  
  <p>I've done this before and it works fine, but in that scenario both applications were sharing the same code base.</p>
  
  <p>In this instance, they are separate applications. This is because i am prototyping a solution where two platform-independent applications on the same top level domain can share a authentication cookie.</p>
  
  <p>Can anyone tell me what i's missing, or provide an alternative solution.</p>
  
  <p>I've read all the related questions, but the answer is usually 2) above.</p>