title: Forms authentication & subdomain
body: <p>I'm trying to use forms authentication that will work for both my top level domain &amp; sub domains.</p>
  
  <p>for example, if I log in with this domain: <em>mydomain.com</em> and afterwards going to <em>www.mydomain.com</em> i want to have the ability to identify the user who logged on to <em>mydomain.com</em> (it's the same application).</p>
  
  <p>i'm using the following in my <strong>web.config</strong> file:</p>
  
  <pre><code>&lt;authentication mode="Forms"&gt;
    &lt;forms loginUrl="~/Account/LogOn" domain="mydomain.com" timeout="2880" /&gt;
  &lt;/authentication&gt;
  </code></pre>
  
  <p>This is an <strong>mvc</strong> project, and i'm getting the user id with the following <strong>API</strong>:</p>
  
  <pre><code>HttpContext.Current.User.Identity.Name
  </code></pre>
  
  <p>The creation of form authentication cookie is done by the following api after performing openid logon to the user:</p>
  
  <pre><code>FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
  </code></pre>
  
  <p>I can see that the authentication cookie is being sent to both domain but only the domain that the authentication was made against recognizes the user.</p>
  
  <p>Am i doing something wrong?</p>
  
  <p>Thanks,
  Lior </p>