checkbox问题?
/// <summary>/// 登陆
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnlogin_Click(object sender, EventArgs e)
{
Users u = new Users();
string username = txtname.Text;
string password = txtpwd.Text;
u = UserBLL.UserBll.GetUsersLoginBll(username,password);
if (u != null)
{
Session["session"] = u;//把用户名保存到session
Response.Redirect("Default.aspx");
}
else
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(),"","alert('用户名或密码错误!');",true);
//Response.Redirect("Login.aspx");
}
if (this.cb1.Checked=true)//判断登录名和密码是否正确和是否选择了记住用户名和密码的复选框
{
//判断客户端浏览器是否存在该Cookie 存在就先清除
if (Request.Cookies["username"] != null && Request.Cookies["password"] != null)
{
Response.Cookies["username"].Expires = System.DateTime.Now.AddSeconds(-1);//Expires过期时间
Response.Cookies["password"].Expires = System.DateTime.Now.AddSeconds(-1);
}
else
{
//向客户端浏览器加入Cookie (用户名和密码 最好是使用MD5加密)
HttpCookie hcUserName1 = new HttpCookie("username");
hcUserName1.Expires = System.DateTime.Now.AddMonths(1);//1个月
hcUserName1.Value = username;
HttpCookie hcPassword1 = new HttpCookie("password");
hcPassword1.Expires = DateTime.Now.AddMonths(1);
hcPassword1.Value = password;
Response.Cookies.Add(hcUserName1);
Response.Cookies.Add(hcPassword1);
}
}
}
选择了保存登陆 客户端没有cooki记录?请高手指点 --------------------编程问答--------------------
--------------------编程问答-------------------- if (this.cb1.Checked==true)//判断登录名和密码是否正确和是否选择了记住用户名和密码的复选框
if (this.cb1.Checked==true)//判断登录名和密码是否正确和是否选择了记住用户名和密码的复选框
{
//判断客户端浏览器是否存在该Cookie 存在就先清除
if (Request.Cookies["username"] != null && Request.Cookies["password"] != null)
{
Response.Cookies["username"].Expires = System.DateTime.Now.AddSeconds(-1);//Expires过期时间
Response.Cookies["password"].Expires = System.DateTime.Now.AddSeconds(-1);
}
else
{
//向客户端浏览器加入Cookie (用户名和密码 最好是使用MD5加密)
HttpCookie hcUserName1 = new HttpCookie("username");
hcUserName1.Expires = System.DateTime.Now.AddMonths(1);//1个月
hcUserName1.Value = username;
HttpCookie hcPassword1 = new HttpCookie("password");
hcPassword1.Expires = DateTime.Now.AddMonths(1);
hcPassword1.Value = password;
Response.Cookies.Add(hcUserName1);
Response.Cookies.Add(hcPassword1);
}
}
}
选择了保存登陆 客户端没有cooki记录?请高手指
--------------------编程问答-------------------- ............ --------------------编程问答--------------------
顶
补充:.NET技术 , ASP.NET