在登入的时候,写入cookie,代码如下:
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("xx");
System.Text.StringBuilder sbi = new System.Text.StringBuilder();
sbi.Append(this.txtName.Text.Trim().ToString());
sbi.Append("#");
sbi.Append(this.txtPas.Text.Trim().ToString());
MyCookie.Values.Add("",sbi.ToString());
MyCookie.Expires = DateTime.Now.AddDays(1);

Response.Cookies.Add(MyCookie);

Session["UserName"]=Ituser.username;
Session["flag"]="test";
Response.Redirect("middle.aspx");
}
catch(Exception ex)
{
this.msg.Text="得到错误信息!" + ex.Message;
}
}
else
{
this.msg.Text="对不起,请输入正确的用户名与密码!";
}这样写入后,读取正常。。现在我在ASP里头进行分割,代码:
if Request.Cookies("xx") <> "" then     
sp = split((Request.Cookies("xx")),"#")
eUserName = sp(0)
eUserPassword = md5(sp(1))
else                                         
eUserName = ReplaceStr(Request.Form("UserName"))
eUserPassword = ReplaceStr(Request.Form("UserPassword"))
eUserPassword=md5(eUserPassword)
end if
        .....(一些通过数据库而查询判断)
       成功登入后,写入asp的session
       If strCheckLogin = "成功登陆" Then
           Session("UserName") = eUserName
           Session("UserPassword")=eUserPassword
           Response.write main.asp
       end if为啥得到的Session("UserName")为空呢?谢谢!