日期:2014-05-17 浏览次数:20417 次
#region "登陆"
protected void btnlogin_Click(object sender, EventArgs e)
{
HttpCookie userId = new HttpCookie("loginId");
//HttpCookie userPwd = new HttpCookie("loginPwd");
HttpCookie roleId = new HttpCookie("roleId");
string name= txtUserName.Text.Trim();
string pwd = txtPwd.Text.Trim();
string roles = ddlselect.SelectedValue;
int result = SEC_USERManager.GetLoginByIdPwd(name, pwd);
if (result>0)
{
userId.Value = name;
//userPwd.Value = pwd;
roleId.Value = roles;
//设置过期时间
userId.Expires = DateTime.Now.AddDays(1);
//userPwd.Expires = DateTime.Now.AddMinutes(1);
roleId.Expires = DateTime.Now.AddDays(7);
Response.Cookies.Add(userId);
//Response.Cookies.Add(userPwd);
Response.Cookies.Add(roleId);
Response.Redirect("Main.aspx");
}
else
{
Response.Write("请重新登陆");
return;
}
}
#endregion