IE获取不到Response添加的cookie的有关问题
IE获取不到Response添加的cookie的问题
项目中发现一个奇怪的事情,用IE8.0 IE9.0浏览器,用户第一次登陆后,正常转到主页面,然后退出登录,再一次登录,页面始终在登录界面,原因是无法读取到cookie。但是在FF中,相同的操作下,没有任何问题。很纠结。。。
这个是AJAX登录中的代码
项目中发现一个奇怪的事情,用IE8.0 IE9.0浏览器,用户第一次登陆后,正常转到主页面,然后退出登录,再一次登录,页面始终在登录界面,原因是无法读取到cookie。但是在FF中,相同的操作下,没有任何问题。很纠结。。。
这个是AJAX登录中的代码
HttpCookie httpCookie = null;
string name = "UserInfo";
if (context.Request.Cookies[name] == null)
{
httpCookie = new HttpCookie(name);
httpCookie.Path = "/";
if (context.Request["autoLogin"] == "checked") httpCookie.Expires = DateTime.MaxValue;
else httpCookie.Expires = DateTime.Now.AddHours(1);
httpCookie.Value = context.Server.UrlEncode(myuser.CombineUserInfo());
context.Response.Cookies.Add(httpCookie);
}
else
{
try
{
httpCookie = context.Request.Cookies[name];
httpCookie.Value = context.Server.UrlEncode(myuser.CombineUserInfo());
if (context.Request["autoLogin"] == "checked") httpCookie.Expires = DateTime.MaxValue;
else httpCookie.Expires = DateTime.Now.AddHours(1);
httpCookie.Path = "/";
context.Response.Cookies.Add(httpCookie);