The cookie is still valid after 30 minutes, although I have set a longer expiration time

Source: Internet
Author: User

I useFormsAuthentication, use the followingCodeSetCookieThe expiration time of is set3Days

If (validateuser (txtusername. Text, txtpassword. Text ))
{
Httpcookie

authenticationcookie = formsauthentication. getauthcookie (txtusername. text, true);
authenticationcookie. expires = datetime. now. adddays (3); // 3 days
response. cookies. add (authenticationcookie);
response. redirect (formsauthentication. getredirecturl (txtusername. text, true);
}

But the actual running result is:CookieThe expiration time of is still30Minutes (this is where I amWeb. config), Instead3Days

.

Why? Please advise, thank you

[Answer:]

Web. configTo set a smooth expirationSlidingexpirationIsFalse

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.