Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to know how to use 'remember me' in c# asp.net application.
the criteria is once user logged in a system the password must be stored in cookies if they clicked the remember me option for next time usage in the same system

pls give me answer...its very urgent
Posted
Comments
sujit3 19-Jul-12 8:31am    
txtPWD.Text.Attributes.Add("value", Request.Cookies["PWD"].Value);
i got error in this line
Attributes does not coming .how to solve this pblm

try following code
if (chkRememberPassword.Checked == true) 
{ 
Response.Cookies["UName"].Value = txtUName.Text; 
Response.Cookies["PWD"].Value = txtPWD.Text; 
Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(2); 
Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(2); 
} 
else 
{ 
Response.Cookies["UName"].Expires = DateTime.Now.AddMonths(-1); 
Response.Cookies["PWD"].Expires = DateTime.Now.AddMonths(-1); 
} 


Paste the following code snippet in page load

C#
if (!IsPostBack) 
{ 
if (Request.Cookies["UName"] != null) 
txtUName.Text= Request.Cookies["UName"].Value; 
if (Request.Cookies["PWD"] != null) 
txtPWD.Text.Attributes.Add("value", Request.Cookies["PWD"].Value); 
if (Request.Cookies["UName"] != null && Request.Cookies["PWD"] != null) 
chkRememberPassword.Checked = true; 
} 
 
Share this answer
 
Comments
Amir Mahfoozi 21-Jan-12 0:14am    
+5
'remember me'is a part of Browsers
 
Share this answer
 
 
Share this answer
 

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