Home
Manage Your Code
Snippet: Remember Password functionality (ASP.NET)
Title: Remember Password functionality Language: ASP.NET
Description: Remember Password functionality Views: 607
Author: pavan bandi Date Added: 10/1/2007
Copy Code  
it is in code behined //  If chkRemember.Checked = True Then
                    Dim cookie As New HttpCookie(txtUserName.Text)
                    Response.Cookies.Add(cookie)
                    cookie.Values.Add("", hdnPwd.Value + ";")
                    Response.Cookies(txtUserName.Text).Expires = DateTime.Now.AddDays(15)
                End If
///



javascript


write this under onfocus of password control///
	function readCookie()
			{
				var txtuname= document.getElementById('txtUserName');
				var txtpass= document.getElementById('hdnPwd');
				if (document.cookie.length>0 && txtuname.value.length>0 )
				{
					// check the index of the username that is entered by user in Username text box </SPAN>
					var c_start=document.cookie.indexOf(txtuname.value);
					if (c_start!=-1)
					{ 
						var c_end=document.cookie.indexOf(";",c_start);
						if (c_end==-1) 
						{
							c_end=document.cookie.length;
						}
						var value= unescape(document.cookie.substring(c_start,c_end));
						var arr = new Array(10);
						arr= value.split('=');
						// if only 0ne equal sign is present that is default one </SPAN>
						if(arr[0]==txtuname.value && arr.length==2)
						{
							txtpass.value=arr[1];
						}
						// if the password contain =(equal) signs in it </SPAN>
						else if(arr[0]==txtuname.value && arr.length > 2)
						{
							var pass=arr[1];
							for(i=2;i<arr.length;i++)
							{
								pass += arr[i];
							}
							txtpass.value=pass;
						}
						else
						{
							txtpass.value="";
						}
					}
					else
					{
						txtpass.value="";
					}
				}
				else
				{
					txtpass.value="";
				}

			}