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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top