title: Asp.Net MVC5 How to ensure that a cookie exists?
body: <p>I'm new to MVC (5). In order to add localization support to my website I added a "<strong>Language</strong>" field to my <code>ApplicationUser : IdentityUser</code> </p>
  
  <p>What's the best approach to now <strong>store this information in the browser and ensure that it gets re-created</strong> even if the user manually deletes it?</p>
  
  <hr>
  
  <p><em>TL; but I've got time</em></p>
  
  <p>What I've tried until now:</p>
  
  <p>I started creating a <strong>cookie</strong> in my method <code>private async Task SignInAsync(ApplicationUser user, bool isPersistent)</code> but I notice that:</p>
  
  <ol>
  <li><p>This method is not used if the user is already authenticated and automatically logs in using the <strong>.Aspnet.Applicationcookie</strong> and my language cookie could be meanwhile expired (or been deleted).</p></li>
  <li><p>A user could manually delete the cookie, just for fun.</p></li>
  </ol>
  
  <p>I thought about checking its existence in the controller (querying the logged user and getting it from the db) and it works but I'd need to do it in EVERY controller. I'm not sure is the correct way to do this.</p>
  
  <p>Any suggestion about how to approach this problem and guarantee that the application has a valid "language cookie" on every request?</p>