当前位置: 代码迷 >> ASP.NET >> CSDN登陆解决方案
  详细解决方案

CSDN登陆解决方案

热度:1348   发布时间:2013-02-25 00:00:00.0
CSDN登陆
想做一个仿Csdn的登陆,主要是实现2周内不用再登陆,在注册页中代码为
  string name = this.UserName.Text;
  string pwd = this.PassWord.Text;
  People p=new People();
  p.Name=name;
  p.Pwd=pwd;
  SqlConnection con=new SqlConnection("server=.database=People;uid=sa");
  SqlCommand cmd=new SqlCommand("select count(*) from login where name='"+p.Name+"'and pwd='"+p.Pwd+"'",con);
  if(Convert.ToInt32 (cmd.ExecuteScalar())>0)
  {
  HttpCookie cookie_name = new HttpCookie("login","true");
  cookie_name.Expires=DateTime.Now.AddDays(20);
  Response.Cookies.Add(cookie_name);
   
  } 
请问在主页Page_Load中应该怎样判断,我用Request.Cookies("login")点不出来value,郁闷中~~请高手指点一下,谢谢

------解决方案--------------------------------------------------------
C# code
HttpCookie myCookie = Request.Cookies["Login"];if (myCookie != null){      //查询数据库判断myCookie的值是否正确              }
  相关解决方案