cookie得不到值?
像这样的代码:
case "itshop ":
csover.reg.bin.user_Itsun Ituser=new user_Itsun();
Ituser.username=this.txtName.Text.Trim();
Ituser.Password=calyx.reg.bin.Function_all.Encrypts(this.txtPas.Text.Trim(),1);
if(Ituser.Itsun_Login())
{
try
{
HttpCookie MyCookie = new HttpCookie( "itshop ");
MyCookie.Value = "admin ";
Response.Cookies.Add(MyCookie);
Response.Redirect ( "middle.aspx ");
}
catch(Exception ex)
{
this.msg.Text= "得到错误信息! " + ex.Message;
}
}
else
{
this.msg.Text= "对不起,请输入正确的用户名与密码! ";
}
break;
执行这段代码后,为啥在asp中运用 response.write Request.Cookies( "itshop ")打印出来是空白的呢?
------解决方案--------------------MyCookie.Value = "admin ";
后面加
vb.net
MyCookie.Expires=system.DateTime.Now.AddDays(1)