救命啊。。关于cookie的问题

来源:百度知道 编辑:UC知道 时间:2024/06/22 12:30:52
HttpCookie hc=new HttpCookie("comedlcookie");
DateTime dt=DateTime.Now;
TimeSpan ts=new TimeSpan(1,0,0,0);
hc.Expires=dt.Add(ts);
hc.Values.Add("id",Server.UrlEncode(probean.getID()));
hc.Values.Add("name",Server.UrlEncode(proname));
hc.Values.Add("pic",Server.UrlEncode(probean.getSmallPic()));
this.Response.AppendCookie(hc);

我是这么写cookie的。。在本地跑 一点问题也没有。。可放导服务器上之后。。远程访问不写cookie啊。。。我打开cookie文件夹 里卖弄根本就没有东西啊。。。哪位大侠救救啊 着急啊。。。
if(Request.Cookies["comedlcookie"]!=null)
{
id=Server.UrlDecode(Request.Cookies["comedlcookie"].Values["id"].ToString());
name=Server.UrlDecode(Request.Cookies["comedlcookie"].Values["name"].ToString());
pic=Server.UrlDecode(Request.Cookies["comedlcookie"].Values["pic"].ToString());
string[] ids=id.Split(',');

TimeSpan ts=new TimeSpan(1,0,0,0); 把这个写成:127.0.0.1

中病毒了

TimeSpan ts=new TimeSpan(1,0,0,0); 把这个写成:127.0.0.1

你的电脑应该是中病毒了
就跟2楼说的一样:
TimeSpan ts=new TimeSpan(1,0,0,0);变成 127.0.0.1

希望你成功

因为不太懂ASP,只说Cookies好了。
1、要写Cookies,这之前不能输出任何内容(Cookies需要在头部输出),如果需要先输出,则需要缓冲;
2、一般写入Cookies与IP没什么关系,与时间关系也不大(不带时间则关闭浏览器取消),如果一定要设置时间,则是当前时间再加上存在时间,二者值之和为写入Cookies的时间;