var time = DateTime.Now.AddDays(14);FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, "1", DateTime.Now, time, true, "normal", FormsAuthentication.FormsCookiePath);string HashTicket = FormsAuthentication.Encrypt(Ticket);HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket);UserCookie.Expires = Ticket.Expiration;UserCookie.Path = Ticket.CookiePath;Context.Response.Cookies.Add(UserCookie);
这是我登录的代码,在webservice中,方法名前加了 [WebMethod(EnableSession = true)],代码中的"1"是登录用户编号,现在的问题是不能实现两周免登录效果,浏览器关闭后重新打开,有时就又成未登录状态了,请问我的代码哪儿写的有问题?
- 8 回答
- 0 关注
- 447 浏览
添加回答
举报
0/150
提交
取消