我在前台JS中写有: document.cookie = "text=" + cookie + ";expires=" + date.toGMTString();
我在后台想要更改这个Cookie的值我是这样写的: if (Request.Cookies["text"] != null)
{
cookie = Request.Cookies["text"].Value.ToString();
//对cookie的值操作
HttpCookie icookie = new HttpCookie("text", "1"); //1 是测试用的值
icookie.Expires = DateTime.Now.AddHours(1);
Response.Cookies.Add(icookie);
}
可是结果发现Cookies["text"]的值没有更改.而且我看Request.Cookie的AllKeys里居然有二个text.请问这是什么问题,应该怎么改.
解决方案 »
- 错误 1 找不到类型或命名空间名称“DotNetTextBox”(是否缺少 using 指令或程序集引用?)
- 新闻发布时的烦恼
- 如何把asp后缀变成aspx?
- 请教两台SQL服务器数据同步的问题,有什么好的解决方案[UP者有分],谢谢
- 再问.shtml网页和.htm、.html的有什么区别?它又有什么好的地方?
- 见一用VB写程序中用DataGrid.currentPageIndex=e.NewPageIndex 来指向新页,请问其中的e是什么类?
- 谁有MCAD的考试题库和电子板英文教材呀?考过的也可以介绍一下经验,非常感谢!
- "基础连接已经关闭"这是怎么回事?
- datagrid,问题,高手请进!!!
- 怎么直接访问xml 文件也可以 ?Schemas 和 XSLT 有什么相同点和不同点 ? dtd 是否属于 Schemas?
- 刚进公司的程序员实习生该怎么适应工作
- Ajax二级联动问题 DropDownList在有的环境显示乱码问题?(高手们,求助啊)
if (Request.Cookies["text"] != null)
{
HttpCookie icookie = Request.Cookies["text"];
icookie.Value = "1";
icookie.Expires = DateTime.Now.AddHours(1);
Response.SetCookie(icookie); }
if (Request.Cookies["text"] != null)
{
cookie = Request.Cookies["text"].Value.ToString();
//对cookie的值操作
Response.Cookies["text"].Value = "1";
Response.Cookies["text"].Expires = DateTime.Now.AddHours(1);
}
{
cookie = Request.Cookies["text"].Value.ToString();
Response.Cookies["text"].Value = "1";
Response.Cookies["text"].Expires = DateTime.Now.AddHours(1);
}
java的Response没有SetCookie的方法,