Session Cookie和会话成为;空";在Asp.net中重定向到另一个页面后
我在用户登录后设置一个会话和一个cookie,在检查某些条件时,用户被重定向到另一个页面,但恰好在页面加载事件之后,会话和cookie设置为NULL。 那有什么问题 这是我的代码:Session Cookie和会话成为;空";在Asp.net中重定向到另一个页面后,session,redirect,cookies,null,Session,Redirect,Cookies,Null,我在用户登录后设置一个会话和一个cookie,在检查某些条件时,用户被重定向到另一个页面,但恰好在页面加载事件之后,会话和cookie设置为NULL。 那有什么问题 这是我的代码: if (HttpContext.Current.Request.Cookies["LastSession"] != null) HttpContext.Current.Response.Cookies.Remove("LastSession"); HttpCookie cookie
if (HttpContext.Current.Request.Cookies["LastSession"] != null)
HttpContext.Current.Response.Cookies.Remove("LastSession");
HttpCookie cookieLogSession = new HttpCookie("LastSession", strLogInID);
cookieLogSession.Expires = dtNow.AddDays(7);
//cookieLogSession.Path = "/";
HttpContext.Current.Response.Cookies.Add(cookieLogSession);
if (HttpContext.Current.Request.Cookies["Ad_LastSession"] != null)
HttpContext.Current.Response.Cookies.Remove("Ad_LastSession");
HttpCookie cookie = new HttpCookie("Ad_LastSession");
cookie.Value = (a variable);
//cookie.Path = "/";
cookie.Expires = dtNow.AddDays(7);
HttpContext.Current.Response.Cookies.Add(cookie);
另一个页面-是在同一个域吗?@AllanS.Hansen是的。域是相同的。是否可以在Windows或webconfig中进行任何特定设置?顺便说一下。web.config中的enableSessionState=“true”