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

T

time is life

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.Text,true);
authenticationCookie.Expires=DateTime.Now.AddDays(3);//3天
Response.Cookies.Add(authenticationCookie);

Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUserName.Text,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!
 
D

Dominick Baier

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

time is life

to Dominick Baier:

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

Dominick Baier

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top