0

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,

3
Contributors
2
Replies
5
Views
9 Years
Discussion Span
Last Post by SheSaidImaPregy
0

Use session variables:

Session("username") = textbox1.Text

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.