Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
2.75/5 (3 votes)
See more:
Hi,
I set the Cookie for Username and password field in asp.net mvc. Again i logged username only fetched not password. I need to retrieve password in mvc2.0,C#.
Thanks in advance..

SQL
public ActionResult LogOn()
   {
       LogOnModel mod =new LogOnModel();
       if (Request.Cookies["userid"] != null)
          mod.UserName = Request.Cookies["userid"].Value;
       if (Request.Cookies["pwd"] != null)

        <big>   mod.Password = Request.Cookies["pwd"].Value;</big>
       if (Request.Cookies["userid"] != null && Request.Cookies["pwd"] != null)
           mod.RememberMe = true;
       return View(mod);
   }
Posted
Updated 11-Oct-13 7:06am
v3
Comments
Stephen Hewison 10-Oct-13 4:26am    
What have you tried so far? What problems have you run into?
Eduard Keilholz 10-Oct-13 7:14am    
We're not going to create anything for you. Post the code of what you tried already and we will help you create it.

there is something called Cookie or HttpCookie that is a memory storage on hardware so even you turn off the pc it will be still saved so you have to save these data in the following memory, check below links:

Implement Remember me on Login Page[^]
http://www.dotnetspark.com/kb/178-remember-me-option-asp-net.aspx[^]
http://stackoverflow.com/questions/18082710/remember-me-with-asp-net-web-pages[^]
 
Share this answer
 
v2
after successfully login, add code like this :-

if (chkRemember.Checked)
{
HttpCookie User = new HttpCookie("UserName", email);
HttpCookie SBPassword = new HttpCookie("UserPassword", txtPassword.Text);
HttpCookie Remember = new HttpCookie("UserRemember", "True");
User.Expires = DateTime.Now.AddMonths(3);
Response.Cookies.Add(User);
SBPassword.Expires = DateTime.Now.AddMonths(3);
Response.Cookies.Add(SBPassword);
Remember.Expires = DateTime.Now.AddMonths(3);
Response.Cookies.Add(Remember);
}
else
{
HttpCookie User = new HttpCookie("UserName", "");
HttpCookie SBPassword = new HttpCookie("UserPassword", "");
HttpCookie Remember = new HttpCookie("UserRemember", "False");
User.Expires = DateTime.Now.AddMonths(3);
Response.Cookies.Add(User);
SBPassword.Expires = DateTime.Now.AddMonths(3);
Response.Cookies.Add(SBPassword);
Remember.Expires = DateTime.Now.AddMonths(3);
Response.Cookies.Add(Remember);
}
 
Share this answer
 
 
Share this answer
 
Comments
Member 14843970 16-Jul-20 0:50am    
please guide me in reference code for remember me option (login page)in .Net core because i fond code in mvc but i need code in .net core

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900