Re: Cookie expires after 30 mins when I set longer expiring time..



Have a look at the source of FormsAuthenticationModule - i might be wrong (too long ago) - but i think you will find the answer there.


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

to Dominick Baier:

Because I want to allow users to custom the expiring time of their
cookie.

"Dominick Baier" wrote:

The expiration time gets regularly overwritten bei the
FormsAuthModule - why don't use set this in the config element?

-----
Dominick Baier (http://www.leastprivilege.com)
Developing More Secure Microsoft ASP.NET 2.0 Applications
(http://www.microsoft.com/mspress/books/9989.asp)

I use Forms Authentication in my web application, and use the
following codes to set the expire time of cookie to 3 days.

if( ValidateUser( txtUserName.Text , txtPassword.Text ))
{
HttpCookie
authenticationCookie=FormsAuthentication.GetAuthCookie(txtUserName.T
ex
t,true);
authenticationCookie.Expires=DateTime.Now.AddDays(3);//3天
Response.Cookies.Add(authenticationCookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUserName.Tex
t,
true));
}
but the actual result is: the cookie's expire time is still 30 mins
which is set in web.config instead of 3 days.
Why does this happen and how to solve it.

please help me , thank you very much!



.



Relevant Pages

  • Re: Cookie expires after 30 mins when I set longer expiring time..
    ... Because I want to allow users to custom the expiring time of their cookie. ... "Dominick Baier" wrote: ... following codes to set the expire time of cookie to 3 days. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: asp.net login contol using url redirect
    ... Dominick Baier [DevelopMentor] wrote: ... > You have to manually issue the cookie and set the Domain property on the ... >> If however I include the site in a frame on another site, e.g., ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Question about cookie protection and FormsAuthentication.Encry
    ... The FormsAuthenticationModule has to read the cookie on every request - the protection setting tells the module if the cookie is ought to be encrypted and signed. ... Dominick Baier ... a ticket and use it to logon to your application - thats the ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Cookie expires after 30 mins when I set longer expiring time...
    ... The expiration time gets regularly overwritten bei the FormsAuthModule - why don't use set this in the config element? ... Dominick Baier ... Developing More Secure Microsoft ASP.NET 2.0 Applications ... following codes to set the expire time of cookie to 3 days. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: When does the Roles/Username get set in HTTPContext?
    ... Dominick Baier ... specifically see anything like a cookie being written local, ... although I did see the 302 redirect to my next page. ... the cookie set? ...
    (microsoft.public.dotnet.framework.aspnet.security)