Last post Jun 19, 2010 01:10 AM by JonathanWood
Apr 11, 2008 06:03 PM|TopographicOceans|LINK
Could someone please help me with this?
I want a User to be able to come back to a Page without having to Log In again.
Example: a User Logs In with Login.aspx . . they are taken to the MainPage.aspx . .
they return to MainPage.aspx the next day and don't have to Log In
(this will only happen if the User checks the "remember me" box)
I'm not using the WebSite Administration Tool.
I just want to secure a few pages, using WebConfig:
<deny users="?" />
This is what I have in the Login.aspx - Log_In_Click button:
... after checking password:
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);
ck.Expires = tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
How do I implement it so the user doesn't have to log back in if (chkPersistCookie.Checked) is checked? Thanks...........
Apr 11, 2008 06:23 PM|mfouwaaz|LINK
Are you using the login control? If so you can change the property 'RememberMeSet' to True -- that will make the cookie persist. If you do not want the 'remember me' box to be displayed you can also change the property 'DisplayRememberMe' to False.
I hope this was your question!
Apr 11, 2008 06:59 PM|TopographicOceans|LINK
I'm not using the WebSite Administration Tool. I'm coding it all myself.
Apr 12, 2008 03:28 PM|TopographicOceans|LINK
I guess I should check the cookie in the Log In page first.
Apr 15, 2008 08:04 AM|XiaoYong Dai – MSFT|LINK
AuthenticationTicket will help you keep a User logged in after signing in. The ticket is passed as the value of the forms authentication cookie with each request and is used by forms authentication, on the server, to identify an authenticated user.
If the ticket is marked as persistent, where the cookie is stored on the client box, browsers can use the same authentication cookie to log on to the Web site any time. However, we can use the
FormsAuthentication.SignOut method to delete persistent or non-persistent cookies explicitly.
Please view this link for detailed information
Jun 19, 2010 01:10 AM|JonathanWood|LINK
I don't know what you guys are talking about.
When I set the 'Keep me logged in' option to true, it keeps me logged in for around 15-20 minutes. Has anyone actually tried this the next day?