登录核心方法:
private void Signin(string curUserId) { System.Web.Security.FormsAuthenticationTicket tk = new FormsAuthenticationTicket(1, curUserId, DateTime.Now, DateTime.Now.AddDays(1), true, "", System.Web.Security.FormsAuthentication.FormsCookiePath ); string key = System.Web.Security.FormsAuthentication.Encrypt(tk); //得到加密后的身份验证票字串 HttpCookie ck = new HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, key); //ck.Domain = System.Web.Security.FormsAuthentication.CookieDomain; // 这句话在部署网站后有用,此为关系到同一个域名下面的多个站点是否能共享Cookie HttpContext.Current.Response.Cookies.Add(ck); HttpContext.Current.Response.Cookies["MenuStyle"].Expires = DateTime.Now.AddDays(1); HttpContext.Current.Response.Cookies["PageSize"].Expires = DateTime.Now.AddDays(1); HttpContext.Current.Response.Cookies["TableSink"].Expires = DateTime.Now.AddDays(1); }