title: ASP.Net delete/expire session cookies
body: <p>We have a number of internal company ASP.Net applications.  All use Forms Authentication and all are session based...</p>
  
  <p>What I am trying to do is when a user logs out of one application he/she is logged out of all applications.</p>
  
  <p>I have some logic that iterates the cookies collection.  I can see all the other ASP.Net applications but I can not remove them.</p>
  
  <p>Im currently using the following logic:</p>
  
  <pre><code>// expire all asp.net app tickets
          string[] allDomainCookes = HttpContext.Current.Request.Cookies.AllKeys;
  
          foreach (string domainCookie in allDomainCookes)
          {
              if (domainCookie.Contains("ASPXAUTH"))
              {
                  var expiredCookie = new HttpCookie(domainCookie) { Expires = DateTime.Now.AddDays(-1) };
                  HttpContext.Current.Response.Cookies.Add(expiredCookie);
              }
          }
          HttpContext.Current.Request.Cookies.Clear();
  </code></pre>
  
  <p>For some reason they are not being removed.  I know they are all there because I have written them to the page.  They are just not being removed....is this because these are session cookies?  </p>
  
  <p>Also I should add they are all sub-domains of the some domain so ownership should not be an issue?</p>