登录时记住密码
来源:互联网 发布:企业宣传制作软件 编辑:程序博客网 时间:2024/04/30 10:42
//实现登录;
string loginId = this.TextBox1.Text;
string loginPwd = this.TextBox2.Text;
BLL.UserManager um = new BLL.UserManager();
Model.User currentUser;
bool isSuccess = um.Login(loginId, loginPwd, out currentUser);
if (isSuccess) //登录成功;
{
//处理记住密码-- 必须通过cookie记下来;页面类的User属性才能取得当前用户的信息
if (this.CheckBox1.Checked)
{
string ddlValue = this.ddlTime.SelectedValue;
DateTime outTime = DateTime.Now;
if(ddlValue=="1年")
outTime = DateTime.Now.AddYears(1);
else if(ddlValue=="1个月")
outTime = DateTime.Now.AddMonths(1);
else if(ddlValue=="1周")
outTime = DateTime.Now.AddDays(7);
//MS设计一个票据类来封装用户信息;
//1、生成票据;票据等相关安全处理的类:System.Web.Security
FormsAuthenticationTicket ticket =
new FormsAuthenticationTicket(1, currentUser.LoginId, DateTime.Now, outTime, true, currentUser.Name, FormsAuthentication.FormsCookiePath);
//2、对票据进行加密;
string enctrytData = FormsAuthentication.Encrypt(ticket);
//3、将加密后的数据写到cookie中;
HttpCookie cookie = new HttpCookie("userInfo");
cookie.Value = enctrytData;
cookie.Expires = outTime;
Response.Cookies.Add(cookie);
//4跳转到对应的某一页面;
FormsAuthentication.RedirectFromLoginPage(currentUser.Name, true);
//Response.Redirect(FormsAuthentication.GetRedirectUrl(currentUser.LoginId, true));
//Response.Redirect("Cart.aspx");
}
}
else
{
this.litMessage.ForeColor = Color.Red;
this.litMessage.Text = "请检查帐号与密码";
}
- 登录时记住密码
- 登录时记住密码功能实现js
- 登录实现记住密码
- android登录记住密码
- 记住密码登录
- jquery记住登录密码
- 登录记住密码
- 登录界面 记住密码
- JavaScript登录记住密码
- 用户登录记住密码
- 用户登录记住密码
- 用户登录记住密码
- 用户登录记住密码
- 用户登录记住密码
- 用户登录记住密码
- 用户登录记住密码
- 用户登录记住密码
- 用户登录记住密码
- paip.分布式应用系统java c#.net php的建设方案
- 联想thinkcenter电脑如何设置启动方式
- javascript深入理解js闭包
- Python Tkinter Grid布局管理器详解
- CentOS下用Tomcat+Zookeeper+Nginx+Solr完美搭建SolrCloud平台(一)
- 登录时记住密码
- js闭包总结
- Android4.2.2 Gallery2源码分析(2)——发现Gallery.java
- CSS中行间距问题
- C#关于构造函数初始化器的使用
- Java里面是怎么解决没有链表这个问题的啊?
- oracle 建立表空间
- JComboBox,JList
- gridview自定义添加一列