keep me signed in
private void ChkRememberme_Function()
{
#region -- Implemanting Rememberme Functionality --
try
{
//string UserName = string.Empty;
// string Password = string.Empty;
// Storing the User name and Password
//if (txtUsername.Text != "")
//{
// UserName = txtUsername.Text.Trim();
//}
//if (txtPassword.Text != "")
//{
// Password = txtPassword.Text.Trim();
//}
// Storing it in the Cookies
if (ChkRememberme.Checked == true)
{
Response.Cookies["UserName"].Value = txtUsername.Text;
Response.Cookies["Password"].Value = txtPassword.Text;
Response.Cookies["UserName"].Expires = DateTime.Now.AddYears(50);
Response.Cookies["Password"].Expires = DateTime.Now.AddYears(50);
}
else
{
Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1);
Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);
}
//Response.Cookies["UserName"].Value = UserName;
//Response.Cookies["Password"].Value = Password;
}
catch (ArgumentNullException Exc)
{
//lblshowmessage.Text = "Application Error : " + Exc.Message;
}
#endregion
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.Cookies["UserName"] != null && Request.Cookies["Password"] != null)
{
txtUsername.Text = Request.Cookies["UserName"].Value;
txtPassword.Attributes["value"] = Request.Cookies["Password"].Value;
}
lblshowmessage.Visible = false;
}
}
<asp:CheckBox ID="ChkRememberme" runat="server" class="checkbox" Text="Keep me Logged in" />
{
#region -- Implemanting Rememberme Functionality --
try
{
//string UserName = string.Empty;
// string Password = string.Empty;
// Storing the User name and Password
//if (txtUsername.Text != "")
//{
// UserName = txtUsername.Text.Trim();
//}
//if (txtPassword.Text != "")
//{
// Password = txtPassword.Text.Trim();
//}
// Storing it in the Cookies
if (ChkRememberme.Checked == true)
{
Response.Cookies["UserName"].Value = txtUsername.Text;
Response.Cookies["Password"].Value = txtPassword.Text;
Response.Cookies["UserName"].Expires = DateTime.Now.AddYears(50);
Response.Cookies["Password"].Expires = DateTime.Now.AddYears(50);
}
else
{
Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1);
Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);
}
//Response.Cookies["UserName"].Value = UserName;
//Response.Cookies["Password"].Value = Password;
}
catch (ArgumentNullException Exc)
{
//lblshowmessage.Text = "Application Error : " + Exc.Message;
}
#endregion
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.Cookies["UserName"] != null && Request.Cookies["Password"] != null)
{
txtUsername.Text = Request.Cookies["UserName"].Value;
txtPassword.Attributes["value"] = Request.Cookies["Password"].Value;
}
lblshowmessage.Visible = false;
}
}
<asp:CheckBox ID="ChkRememberme" runat="server" class="checkbox" Text="Keep me Logged in" />
Comments
Post a Comment