I have two text boxes for login (not using ASP.NET2.0 login control) for username and password and one checkbox for "Remember Password".I want to remember password on the check of checkbox.
Do I have to use cookies?Is there any other way to achieve that since if the user had disabled cookies then this can't be achieved.

I have tried it with cookies but not able to succeed,can anybody suggest me the code ...
no matter its using cookies or not......

my code is
protected void btnLogin_Click(object sender, EventArgs e)
{
try
{


HttpCookie myCookie = new HttpCookie("myCookie");
Response.Cookies.Remove("mycookie");
Response.Cookies.Add(myCookie);
myCookie.Values.Add("UserName", txtUserName.Text.ToString());
myCookie.Values.Add("Password", txtPassword.Text.ToString());
DateTime dtxpiry = DateTime.Now.AddDays(15);
if (chkRememberPassword.Checked == true)
{
if (Request.Cookies["myCookie"] != null)
{
HttpCookie getCookie = Request.Cookies.Get("myCookie");
string userName = getCookie.Values["UserName"].ToString();
string password = getCookie.Values["Password"].ToString();
}
}
for storing and using cookie and if page is valid

if (Page.IsValid)
{
if (validateuser != null)
{

Response.Redirect("abc.aspx");
}
else
{
lblErrorMessage.Visible = true;
lblErrorMessage.Text = "InvalidUser";
}


Thanks in advance,

Recommended Answers

Please go through the following link.You can do it yourself.
Good Luck.

http://www.asp.net/learn/security/tutorial-02-vb.aspx

Jump to Post

All 2 Replies

Use session variables:

Session("username") = textbox1.Text

if Session("username") Is Nothing then response.redirect("login.aspx")

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.