import
System.Net
namespace in your code.
Add the following code to click event of your login button:
if (chkRemember.Checked)
{
HttpCookie cookie = new HttpCookie("YourAppLogin");
cookie.Values.Add("username", txtUsername.Text);
cookie.Expires = DateTime.Now.AddDays(15);
Response.Cookies.Add(cookie);
}
In the code above first we check if user has checked "Remember Me"
checkbox, if its checked then we create a HTTPCookie and we set an expiry date for it.
Now you should add this code to every page that requires login :
if (Request.Cookies["YourApLogin&"] != null)
{
string username = Request.Cookies["YourAppLogin"].Values["username"]);
}
This code checks the cookie and returns Username.