Tuesday, July 21, 2009

 

Code For Remember Me password Checked

protected void UserLogin(object sender, EventArgs e)------>Button_Click
{
if (Membership.ValidateUser(UserName.Text, PassWord.Text))
{
if (RememberDetailsChecked.Checked)
{
HttpCookie c1, c2;
c1 = new HttpCookie("username");
c2 = new HttpCookie("pasword");
c1.Value = UserName.Text;
c2.Value = PassWord.Text;
c1.Expires = DateTime.Now.AddDays(7);
c2.Expires = DateTime.Now.AddDays(7);
Response.AppendCookie(c1);
Response.AppendCookie(c2);
}
else
{
HttpCookie obj1, obj2;
obj1 = Request.Cookies["username"];
obj2 = Request.Cookies["pasword"];
if (obj1 != null && obj2 != null)
{
obj2.Expires = DateTime.Now.AddDays(-1);
Response.AppendCookie(obj2);
}
}
setCookie(UserName.Text);
}
else
{
LoginErrorLabel.Text = "Enter Valid Details *";
}
}
code in page_load...........
if (!Page.IsPostBack)
{
HttpCookie obj1, obj2;
obj1 = Request.Cookies["username"];
obj2 = Request.Cookies["pasword"];
if (obj1 != null && obj2 != null)
{
if(Membership.ValidateUser(obj1.Value, obj2.Value))
{
UserName.Text = obj1.Value;
PassWord.Attributes.Add("value", obj2.Value);
RememberDetailsChecked.Checked = true;
}
}
}

Labels:


Comments: Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Comments [Atom]