//注册时,写cookie
HttpCookie newCookie = new HttpCookie("test",DateTime.Now.ToString());
newCookie.Expires.AddMinutes(10);  //10分钟后过期
newCookie["username"]="aa";
newCookie["pwd"]="aa"; 
Response.Cookies.Add(newCookie);
Label1.Text="注册成功";

页面读取cookie 验证
private string us;
private string pwd;
if(Request.Browser.Cookies==true)    //来判断系统是否支持cookie
{

HttpCookie cookie = Request.Cookies ["test"];
if(cookie!=null)
{
     us=cookie["username"].ToString();
     pwd=cookie["pwd"].ToString();
}
}
//以下验证是简写的,用到的时候是需要连接数据库做验证的
if(us=="aa" && pwd=="aa")
{
     Label2.Text="成功";
}
else
{
     Label2.Text="失败";
}

不过这么做,文件不是加密的,很容易就看见里面的东东,过些时候,我把如何加密这段代码,发出来.

相关文章:

  • 2022-12-23
  • 2021-11-27
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2022-02-22
  • 2022-01-05
  • 2022-12-23
猜你喜欢
  • 2021-08-02
  • 2021-08-24
  • 2021-08-11
  • 2022-02-06
  • 2021-06-21
  • 2021-07-11
  • 2021-09-10
相关资源
相似解决方案