title: Identity cookie loses custom claim information after a period of time
body: <p>I am storing custom claims, such as the user's real name, in the ASP.NET Identity cookie to avoid unnecessary database queries on every request. At least that's what I assume this code is doing:</p>
  
  <pre class="lang-cs prettyprint-override"><code>var identity = await user.GenerateUserIdentityAsync(UserManager);
  identity.AddClaim(new Claim(ClaimTypes.GivenName, user.FirstName)));
  // etc.
  AuthenticationManager.SignIn(new AuthenticationProperties {IsPersistent=true}, identity);
  </code></pre>
  
  <p>This works fine, and I can retrieve these claims with:</p>
  
  <pre><code>private static string GetClaim(string claimType)
  {
    var identity = (ClaimsPrincipal) Thread.CurrentPrincipal;
    var claim = identity.Claims.SingleOrDefault(o =&gt; o.Type == claimType);
    return claim == null ? null : claim.Value;
  }
  </code></pre>
  
  <p>The <code>identity.Claims</code> property contains the following claims, as expected:</p>
  
  <pre class="lang-none prettyprint-override"><code>http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier: ced2d16c-cb6c-4af0-ad5a-09df14dc8207
  http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: me@example.com
  http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider: ASP.NET Identity
  AspNet.Identity.SecurityStamp: 284c648c-9cc7-4321-b0ce-8a347cd5bcbf
  http://schemas.microsoft.com/ws/2008/06/identity/claims/role: Admin
  http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname: My Name
  </code></pre>
  
  <p>The trouble is that after some time (usually several hours), my custom claims seem to disappear - in this example, <code>givenname</code> no longer exists in the enumeration. The user is still authenticated, and all the default claims are still there.</p>
  
  <p>What's going on, and how can I fix this? The only thing I can think of is that the cookie is expiring and being re-issued behind the scenes, but I don't know why (or if) that would happen. </p>