Creating cookie when user submits the Login page with proper credentials
if(UserCredentilas correct)
{
HttpCookie aCookie = new HttpCookie("UserInfo");
aCookie.Values["uname"] = Request.Form["txtEmail"].ToString();
aCookie.Values["pwd"] = Request.Form["txtPassword"].ToString();
if (Request.Form["chk_RememberMe"] != null)
aCookie.Expires = DateTime.Now.AddYears(50);
else
aCookie.Expires = DateTime.Now.AddDays(0);
Response.Cookies.Add(aCookie);
}
Use the following code in javascript of LoginPage
<body onload="javascript:getCookie('UserInfo');"></body>
<script language="javascript" type="text/javascript">
function getCookie(c_name)
{
var i,CooP,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
CooP=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
var CooPar=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
CooP=CooP.replace(/^\s+|\s+$/g,"");
if (CooP==c_name)
{
var CooParList=CooPar.split("&");
var CooCList=CooParList[0].split("=");
document.getElementById('txt_Username').value=CooCList[1];
CooCList=CooParList[1].split("=");
document.getElementById('txt_Password').value=CooCList[1];
document.getElementById('chk_Rememberme').checked=true;
}
}
}
</script>
Tag: remember me code in javascript, remember me code in asp.net, remember me code in asp.net c#, remember me code in php, remember me code in java, remember me asp.net login control
No comments:
Post a Comment