title: Forms authentication issue with Chrome on iPhone
body: <p>I have an MVC 4 website that uses .NET Framework 4.0 and has been deployed with a Windows Server 2003 IIS and I am having problems with forms authentication on an iPhone (especially Chrome browser).</p>
  
  <p><strong>Scenario</strong></p>
  
  <ol>
  <li>I Open Chrome app on the iPhone.</li>
  <li>I go to my website and click Login.  I manage to successfully log into my website using Forms Authentication.</li>
  <li>I leave the website open for 5 minutes doing nothing.</li>
  <li>I come back to my iPhone and click on a link on my website.  I have been logged out.</li>
  <li>I attempt to log in the same way as before.  The log in process does not work.  No errors, it just takes my to my home page (which is what it is supposed to do on successful login).</li>
  </ol>
  
  <p><strong>Other information</strong></p>
  
  <ol>
  <li>Generally Safari on the iPhone does NOT seem to suffer from this problem except... after the issue has gone wrong in Chrome it seems to go wrong in Safari also.  </li>
  <li>The solution seems to be to clear all my cache/cookies and try again 20 minutes or so later.</li>
  <li>My timeout is actually set to 30 minutes so Chrome should not be experiencing this issue logging out anyway.</li>
  <li><p>I've researched this post (<a href="https://stackoverflow.com/questions/4158550/asp-net-forms-authentication-when-using-iphone-uiwebview">Asp.Net Forms Authentication when using iPhone UIWebView</a>) amongst others and tried:-</p>
  
  <p>(a) The UseCookies setting in the web.config</p>
  
  <p>(b) The .browser configuration file</p>
  
  <p>(c) A MachineKey in the web.config</p></li>
  </ol>
  
  <p>Nothing seems to make a difference and the Chrome login seems to stay up only for a minute or two.</p>
  
  <p><strong>Code</strong></p>
  
  <p>The code to create the forms authentication cookie is as follows...</p>
  
  <pre><code>FormsAuthentication.Initialize()
  Dim fat As FormsAuthenticationTicket = New FormsAuthenticationTicket(1, UserID, DateTime.Now, DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes), False, Roles, FormsAuthentication.FormsCookiePath)
  Response.Cookies.Add(New HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(fat)))
  </code></pre>
  
  <p>Any suggestions on how I can resolve this issue?</p>