Hi!
I have some problems with getting my website to log out the authenticated user automatically when the session ends (the user closes the browser).
This is what I have in my web.config:
<authentication mode="Forms">
<forms name="AuthCookie" protection="All" loginUrl="~/default.aspx" path="/" cookieless="UseCookies" timeout="2592000"/>
</authentication>
<authorization>
<allow users="?" />
</authorization>
<membership defaultProvider="ASPPGSqlMembershipProvider" userIsOnlineTimeWindow="20">
<providers>
<clear />
<add name="AspNetSqlMemberShipProvider" applicationName="umbraco4" type="System.Web.Security.SqlMembershipProvider" connectionStringName="UmbracoDb" requiresUniqueEmail="true" enablePasswordReset="true" enablePasswordRetrieval="false"/>
<add name="UsersMembershipProvider" applicationName="umbraco4" type="umbraco.providers.UsersMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" />
<add name="ASPPGSqlMembershipProvider" applicationName="umbraco4"
passwordStrengthRegularExpression="" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
forumUpfileFolderPath="D:\www\files"
type="ASPPG.MembershipProviders.ASPPGSqlMembershipProvider, ASPPGSiteIntegrationPackage"/>
</providers>
</membership>
This is how I log in the user:
if (Membership.ValidateUser(txtUserName.Text, txtPasssword.Text)) {
HttpCookie cookie = FormsAuthentication.GetAuthCookie(txtUserName.Text, false);
cookie.Expires = DateTime.Now.AddDays(1);
cookie.Domain = ConfigurationManager.AppSettings["Level2DomainName"];
HttpContext.Current.Response.Cookies.Add(cookie);
Response.Redirect(Request.Url.ToString());
}
When I close the browser, the user is still logged in. How do I make the website forget the user through an option, so the user himself can decide if the website should remember or not?
Thanks in advance :)
M