是一个跨域的cookies的问题,写入cookies的代码是这样的。
HttpCookie cookie = new HttpCookie("username");
cookie.Value = username;
cookie.Domain = ".abc.com";
Response.Cookies.Add(cookie);但是我要删除这个cookie的时候却怎么都删不掉。
各种方法我都试过了。
HttpCookie cookie = new HttpCookie("username");
cookie.Value = username;
cookie.Domain = ".abc.com";
Response.Cookies.Add(cookie);但是我要删除这个cookie的时候却怎么都删不掉。
各种方法我都试过了。
解决方案 »
- 关于jquery的colorbox插件
- 关于.net发布问题
- asp.net 中 精确 套打 标签,有横,有竖的,哪位有这方面的资料?
- .net的网站安全方面怎么处理啊?
- 软件必须是可执行文件,不能用源代码替代是什么意思??
- datalist里面的和数据绑定的控件如何获得焦点?(高手救救俺吧,我给你们磕头了)
- 简单sql语句
- 软官方的例子--Jobs Site Starter Kit 中当鼠标指向导航的TreeView控件的节点时,节点出现下划线, 且节点的文字变颜色是如何实现的?
- 我刚学.net,请问你们做的顼目是怎么做,
- DropDownList控件如何定义默认值
- 急!EnterpriseLibrary中DAAB的问题...
- 求助:在客户端实现DataGrid上的模板列CheckBox属性的设置,如何判断DataGrid上的模板列CheckBox的属性。
// 加入Cookie的内容略,假设是string str
HttpCookie cookie = new HttpCookie("MyCookie",str);
cookie.Expires = DateTime.Now.AddMinutes(20); // 有效时间20分
Response.Cookies.Add(cookie);
Response.Redirect("..."); // 重定向
然后是删除
Response.Cookies.Remove("MyCookie");
Response.Redirect("....") // 转向无论是添加Cookie还是移除,都不执行。请问解决方案。HttpCookie cookie = Request.Cookies[strKey];
if(null == cookie)
{
//cookie不存在
}
先看看有没有写入客户端cookie=new HttpCookie("www.xx.org");
cookie.Values.Add("UserType", ddlLoginType.SelectedItem.Value);
cookie.Values.Add("UserName", tbUserName.Text.Trim());
cookie.Values.Add("Password", tbPassword.Text.Trim());
cookie.Values.Add("Access",i.ToString());
Response.AppendCookie(cookie);
//检查COOKIE是否已经写入浏览器
cookie = Request.Cookies["www.xx.org"];
if(cookie==null||cookie.ToString()=="")
{
//用session存储
LoginUser loginUser = new LoginUser();
loginUser.UserName = tbUserName.Text.Trim();
loginUser.Password = tbPassword.Text.Trim();
loginUser.UserType = ddlLoginType.SelectedItem.Value;
loginUser.Access = i;
Session["www.xx.org"] = loginUser;
}我以前的代码,没有问题的
>>>页面仅仅是刷新了一次if you debug, does the code get executed at all? by the way, are you doing any validation?>>>然后是删除>>>Response.Cookies.Remove("MyCookie");
>>>Response.Redirect("....") // 转向you probably should set the cookie's Expires property to a time in the past
本来这个cookie以前是没有跨域的,删除cookie都没有问题。后来我加了跨域以后不论是remove clear还是设置过期时间都不能删除掉cookie了。
1.163.com
2.163.com
3.163.com
都会发送cookie
//Response.Cookies.Remove("mycookie");
Response.Redirect("dddddddddddddddddddd.aspx");我测试过..如果用Remove是不能销毁的..设置过期时间才能真正的销毁该Cookie
hck.Value = "" //清空
hck.Domain = "abc.com";
hck.Expires = DateTime.Now.AddYears(-1); //设置无效