The difference between cache cookie, session, Localstorage

Source: Internet
Author: User
Tags sessionstorage

CookiesA cookie is a piece of information that the server temporarily stores on your computer so that the server can identify your computer. When you are browsing the website, the Web server will send a small piece of information on your computer, and the Cookie will help you record the text or choices you make on the site. The next time you visit the same website, the Web server will first see if it has the last cookie information, and if so, it will be based on the contents of the cookie to determine the user, send a specific page content to you |-setcookie.html set a cookie |         getcookie.html Get Setcookie Cookie-√ read test.set.html cookie-x|-test-get.html read Setcookie cookie-√ Read test.set.html-√|-test-set.html set a cookie peer can read cookies to each other Children can read the parent's Cookie The parent cannot read the child's cookie (the root of the cookie at the same level can be resolved)Document.cookie = ' name=value;path=/;expires= ' +odata; Characteristics of Cookies1 must be placed in a server environment, in a domain of 2 unsafe can see 3 cyclical 4 very precious -4k 5 no matter what you see, the read is a string Disadvantages:       1. Browsers generally only allow 300 cookies, 2. A maximum of 20 cookies per site, 3. Each time you request a new page, it is sent in the past, which virtually wastes bandwidth Ps:ie provides a store that can persist user data uerDataIE5.0 start supporting.        Each data is up to 128K, up to 1M under each domain name. This persisted data is placed in the cache and will persist if the cache is not cleaned up. Advantages:Extremely high scalability and availability 1. The size of the session object in the control cookie can be 2. Reduce the likelihood of cookies being cracked by encrypting the Secure Transmission Technology (SSL) by 3. Storing non-sensitive data only in a cookie is not a significant loss if stolen in a timely manner. 4. Control the life cycle of the cookie so that he is not always effective, and the thief is likely to get an expired cookie must know two points: when to write a cookie when to read a cookie

the difference between Ookie and session:The cookie identifies the user by logging information on the client, and the session determines the user's identity by logging information on the server side when to use:1, the session exists server.    If a person uses cookies (such as a member login), the confidential and less-than-used session (such as an administrator login) requires persistent storage with a cookie (which can also be stored in a non-persistent cookie) 2, the cookie data is stored on the client's browser and the session data is placed on the server. 3. Cookies are not very secure, and others can analyze cookies stored locally and make cookie spoofing.    Consider that security should use the session. 4. Session will be saved on the server for a certain period of time. When the number of accesses increases, the performance of your server will be more expensive.    The cookie should be used in consideration of mitigating server performance. 5, a single cookie can not save more than 4K of data, many browsers restrict a site to save up to 20 cookies. LocalstorageIn the higher version of the browser JS provides Sessionstorage and globalstorage.  The localstorage is provided in HTML5 to replace the globalstorage. The Web Storage in HTML5 includes two ways of storage: Sessionstorage and Localstorage. SessionstorageUsed to store data locally in a session, which can only be accessed by a page in the same session and destroyed when the session ends. So sessionstorage is not a persistent local store, just session-Level storagelocalstorage for persistence of local storage, the size of the data is never expired, or 5 m, unless the data is actively deleted.   Every time you request a new page, Localstorage will not be sent in the past. If there is a mistake or missing place want to point out thank you!

The difference between cache cookie, session, Localstorage

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.