用户登录时如何使用复选框记住密码 [英] How we remember password using check box when user login

查看:173
本文介绍了用户登录时如何使用复选框记住密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Web应用程序.我想添加一个功能,如果选中此复选框,该功能可以记住密码...

请帮助我....................................

I am developing web application. i want to add a functionality which remember password if check box is checked...............

plese help me...........................

推荐答案

谢谢你的问题.您可以按照下面的代码.

Thank you for your question. You can follow the bellow code.

private void CustomizeLoginControl()
        {
            
            if (Request.Cookies["MyCookie"] != null)
            {
                TextBox userName = (TextBox)Login1.FindControl("UserName");
                userName.Attributes.Add("value", Request.Cookies["MyCookie"]["username"]);
                TextBox pass = (TextBox)Login1.FindControl("Password");
                pass.Attributes.Add("value", Request.Cookies["MyCookie"]["password"]);

            }

        }
        private void setRememberMe()
        {
            HttpCookie cookie1 = new HttpCookie("MyCookie");

            cookie1.Values.Add("username", Login1.UserName);
            cookie1.Values.Add("password", Login1.Password);

            cookie1.Expires = DateTime.Now.AddDays(1);//cookie Expires 
            HttpContext.Current.Response.AppendCookie(cookie1);
        }



谢谢,
Mamun



Thanks,
Mamun


带着代码片段来到这里怎么办?

使用Cookies.

记住ASP.NET中的用户名和密码
[ ^ ]
也尝试
ASP.NET中的登录控件 [
What about coming here with your code snippet?

Use Cookies.

Remember username and password in ASP.NET
[^]
Also try
Login Control in ASP.NET[^]


这篇关于用户登录时如何使用复选框记住密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆