日期:2014-05-17 浏览次数:20394 次
public void SignIn(FenLei2012.Models.User m) { if (m != null) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, m.UserName, DateTime.Now, DateTime.Now.Add(FormsAuthentication.Timeout), m.RememberMe, m.Roles.Aggregate((i, j) => i + "," + j) ); System.Web.HttpCookie cookie = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName,FormsAuthentication.Encrypt(ticket)); System.Web.HttpContext.Current.Response.Cookies.Add(cookie); } }