title: Asp.net form login Impossible when client date time differ from server
body: <pre><code>FormsAuthenticationUserData userData = new FormsAuthenticationUserData(member.Id, member.Role, member.Gender);
  FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, member.UserName, DateTime.Now, DateTime.Now.AddHours(24), true, userData.Serialize());
  string encTicket = FormsAuthentication.Encrypt(ticket);
  HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
  faCookie.Expires = DateTime.Now.AddHours(25);
  Response.Cookies.Add(faCookie);
  
  string redirectUrl = FormsAuthentication.GetRedirectUrl(member.UserName, false);
  Response.Redirect(redirectUrl, true);
  
  protected void Application_AuthenticateRequest(object sender, EventArgs e)
  {
      HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
      if (authCookie != null)
      {            
          FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
          try
          {
              WebIdentity identity = new WebIdentity(authTicket.Name, authTicket.UserData);
              WebPrincipal currentMember = new WebPrincipal(identity);
              Context.User = currentMember;
          }
          catch
          {
              FormsAuthentication.SignOut();
              FormsAuthentication.RedirectToLoginPage();
              Response.End();
          }
      }
  }   
  </code></pre>
  
  <p>the user cannot login when client date time is greater than server date time (make cookie null and cannot login)</p>
  
  <p>what is solution?</p>
  
  <p>thanx a lot!</p>