求救在二级域名之间实现共享cookies的问题:
我用的是以下方法,在web.config里设置 <authentication mode="Forms" />
写入的是: FormsAuthentication.SetAuthCookie(Session("UserID"), False)
Dim lcookie As HttpCookie = Context.Response.Cookies(FormsAuthentication.FormsCookieName)
lcookie.Domain = ".mydomain.test"
清空的是:FormsAuthentication.SignOut()
Dim lcookie2 As HttpCookie = System.Web.HttpContext.Current.Response.Cookies(FormsAuthentication.FormsCookieName)
lcookie2.Domain = ".mydomain.test"
有时可以清空,有时不行?为什么?
我用的是以下方法,在web.config里设置 <authentication mode="Forms" />
写入的是: FormsAuthentication.SetAuthCookie(Session("UserID"), False)
Dim lcookie As HttpCookie = Context.Response.Cookies(FormsAuthentication.FormsCookieName)
lcookie.Domain = ".mydomain.test"
清空的是:FormsAuthentication.SignOut()
Dim lcookie2 As HttpCookie = System.Web.HttpContext.Current.Response.Cookies(FormsAuthentication.FormsCookieName)
lcookie2.Domain = ".mydomain.test"
有时可以清空,有时不行?为什么?
不对比如说www.163.com的domain应该是163.com
co1.Domain=domain;
co1.Expires=System.DateTime.Now.AddDays(-100);
Response.Cookies.Add(co1);退出的时候设置过期,再FormsAuthentication.SignOut()
加了lcookie2.Expires还是不行,清不掉.
写入时的代码:
FormsAuthentication.SetAuthCookie(Session("UserID"), False)
Dim lcookie As HttpCookie = Context.Response.Cookies(FormsAuthentication.FormsCookieName)
lcookie.Expires = System.DateTime.Now.AddDays(1)
lcookie.Domain = "mydomain.test"
清空时的代码:
Dim lcookie2 As HttpCookie = System.Web.HttpContext.Current.Response.Cookies(FormsAuthentication.FormsCookieName)
lcookie2.Expires = DateTime.Now.AddDays(-100)
lcookie2.Domain = "mydomain.test"
FormsAuthentication.SignOut()
我在1.1环境下出现了,"要加密的数据长度不对"的错误,
我在2.0环境下不会出现错误,却就是在注销时无法退出登录,就是无法清空cookies
快疯了!