Hello,
If a user checks the chkPersistCookie check box when logging in, I want
their session to never expire:
(they don't have to Log In next time, and their Session will never expire).
My Question is : I need to pass a few values over to the new page.
But they can't expire (like Session's) because that would be
a problem for user who checked the chkPersistCookie check box.
So if I save a value to a Session: Session["MemberID"] = MemberID;
What is the best way to have that value persist
on the next page : Response.Redirect("MemberPage.aspx", true);
LogIn_Click
........
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, "DBMJ", DateTime.Now,
DateTime.Now.AddYears(1), chkPersistCookie.Checked, "your custom data");
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
if (chkPersistCookie.Checked)
ck.Expires = tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
Session["MemberID"] = MemberID.ToString();
Response.Redirect("MemberPage.aspx", true);
<location path="MemberPage.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
Thank you
If a user checks the chkPersistCookie check box when logging in, I want
their session to never expire:
(they don't have to Log In next time, and their Session will never expire).
My Question is : I need to pass a few values over to the new page.
But they can't expire (like Session's) because that would be
a problem for user who checked the chkPersistCookie check box.
So if I save a value to a Session: Session["MemberID"] = MemberID;
What is the best way to have that value persist
on the next page : Response.Redirect("MemberPage.aspx", true);
LogIn_Click
........
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, "DBMJ", DateTime.Now,
DateTime.Now.AddYears(1), chkPersistCookie.Checked, "your custom data");
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
if (chkPersistCookie.Checked)
ck.Expires = tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
Session["MemberID"] = MemberID.ToString();
Response.Redirect("MemberPage.aspx", true);
<location path="MemberPage.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
Thank you