Definitions and differences between persistent cookies and session cookies

Source: Internet
Author: User

Session cookies

================

Session cookies are temporary cookie files that will expire and be deleted after you close your browser.

When you restart your browser and return to the site that previously created the cookie for you, this site will not know you. you must log on again. after logon, a new session cookie is generated. your browsing information will be stored in the new cookie, which will remain active until you close the browser again.

Session cookies can only be used by browsers. Other applicationsProgramCannot be shared.

 

Persistent cookies

================

Persistent cookies are stored in a sub-folder of a browser. They exist until they are deleted manually or regularly cleared by the browser.

Persistent cookies can be shared among multiple applications, provided that these applications can access the same cookie store. By default, the expiration time of the persistent cookie is 30 minutes.

If you want to extend the time, you need to add the following line to the website's web. config.

<Forms loginurl = "login. aspx" name = ". aspxformsauth" timeout = "100"/>

 

What does it depend on to enable the persistent cookie? The answer is the implementation of the site's authentication provider.CodeThe snippets are as follows.

Formsauthenticationticket ticket = newFormsauthenticationticket(1, "username", datetime. Now, datetime. Now. addminutes (30), // value of time out property false ,//Value of ispersistent PropertyString. Empty, formsauthentication. formscookiepath );

 

References:

================

Are all cookies the same?

Http://www.allaboutcookies.org/cookies/cookies-the-same.html

Plan Authentication Settings for Web applications (Windows SharePoint Services)

Http://technet.microsoft.com/en-us/library/cc288081 (office.12). aspx

Explained: Forms authentication in ASP. NET 2.0

http://msdn.microsoft.com/en-us/library/ff647070.aspx

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.