我用Forms认证,用下面的代码将cookie的失效时间设置为3

            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));
            }

但是实际运行结果是:cookie的失效时间仍然是30分钟(这个是我在web.config中设置的),而不是3



为什么那?该如何解决,请指教,谢谢

[]

web.config内要设置平滑过期slidingExpiration false

http://msdn2.microsoft.com/zh-cn/library/system.web.security.formsauthentication.slidingexpiration(VS.80).aspx

posted on 2008-04-01 17:41  今夜太冷  阅读(686)  评论(0编辑  收藏  举报