How to set remember me cookie .net c# ?
protected void SetRememberMeCookie()
{
HttpCookie Cookie = Request.Cookies["LoginCookies"];
if (chkRemember.Checked)
{
if (Request.Browser.Cookies)
{
if (Cookie == null) Cookie = new HttpCookie("LoginCookies");
Cookie["UserID"] =
txtUserID.Text.Trim();
Cookie.Expires = DateTime.Now.AddDays(30);
Response.Cookies.Add(Cookie);
}
}
else
{
if (Cookie == null) Cookie = new HttpCookie("LoginCookies");
Cookie.Expires = DateTime.Now.AddDays(-1);
Response.Cookies.Add(Cookie);
}
}
After that call this function on LogIn button click like this:-
//
Set Cookie
SetRememberMeCookie();
No comments:
Post a Comment
Thanks for comments.