Cookie Session Cache

Source: Internet
Author: User
Tags session id

first, Chinese translation

Øcookie: Little Cookie? I exhausted all the methods have not found its Chinese translation, even I have been very trusting powerword to it is only an explanation rather than a translation. (If any person can translate, please be sure to inform Jinshan company let them to update the thesaurus)

Øsession: Session

Øcache: High-speed buffer memory

ii. mechanism of work

Øcookie: Use the client to save the information program.

Øsession: Use server-side to save information.

Øcache: Use cached SRAM to "statically" save the program that writes the information.

If the above "professional" explanation you still do not understand, then we come to "popular" explain them.

1. The mechanism of a Cookie client is that when a user accesses a site, the WEB server sends more than one page to the user and a cookie containing the date and time. The user's browser gets the Cookie at the same time as the page and saves it to a folder on the user's hard disk.

A Cookie is a piece of textual information that you can find on your computer's hard disk, which is usually stored in the C:/Documents and settings/username/cookies (systems older than Win2000 are stored in c:/windows/ Cookies).

So what did the Web server write down through cookies? What's the use of them?

It all depends on how the code for the WEB server is written, but you don't have to worry that the server is writing the cookies in order to save time or provide certain services (no viruses or other suspicious things) for the next time you visit the site. And some information data is encrypted (such as passwords, etc.), of course, you can also set the browser so that it does not record cookies.

Application examples: Some sites that require a user to log on can use cookies to determine if you have logged in, so you don't have to enter the login information every time; some sites can simply take a cookie as a Boolean value to indicate whether your browser has already participated in the vote, avoiding your repeated voting.

2. The mechanism of the session server is to place the user's request information on the Serverõs side to hold the information, and the server uses a structure similar to the hash table to hold the information. When a program needs to create a session for a client's request, the server first checks to see if the client's request already contains a session ID-called the session ID. If a session ID is already included, which indicates that the SES has previously been created for this client Sion, the server will follow the session ID to retrieve this session to use.

This session ID can be saved in a cookie, so that the browser can automatically send the identity to the server according to the rules during the interaction. Since cookies can be artificially banned, there must be other mechanisms to pass the session ID back to the server when the cookie is blocked. One technique that is often used is called URL rewriting, which is to attach the session ID directly behind the URL path.

It is like we go to some shops to buy things, if you are already a member of the store, then the store will give you a membership card, the next time you visit the store as long as you show your membership card can enjoy custom service.

Because the session only ID not identify, so different browsers, different windows open way and different cookie storage mode will have an impact on its identification, it is easy to appear when we often say session chaos.

Or as an example of the above member stores, such as forget to wear a membership card or membership card on the photo is you a few years ago, the shop staff can not be identified, the store will return you a membership card. And at this point in fact you already have two card (session ID) exactly the two cards of the service range is not the same (a card is common, one is a VIP card, when you go to the store again you arbitrarily give the store a card, so you get the service may not be what you want.

Of course, if the program is good to write can avoid this confusion, and sometimes can be a cross application session sharing.

3. The Cache "static" mechanism is more special than the above two methods. Why it is "static" is because it is written to the SRAM, unless the data is rewritten or turned off, the written data will remain unchanged.

Because the CPU's access data is much faster than it is to access data from memory and hard disks, accessing data from memory and hard disk causes the CPU to wait, affecting the speed of the computer. SRAM is accessed faster than other memory and hard drives, so it is used as a cache for computers.

With a cache, you can first write the data to it, you need to read it directly from it, which shortens the CPU wait time. The reason that caching improves the speed of a system is based on a statistical pattern the control system on the motherboard will automatically count which data in the memory will be used frequently, so that the data is in the cache, the CPU to access the data, it will first go to the cache to find, thus improving the overall speed of operation.

iii. Life-Cycle differences

Øcookie

If you do not set an expiration time, the cookie life cycle is the duration of the browser session, and the cookie disappears when the browser window is closed. This lifetime is called a session cookie for browsing session cookies. Session cookies are generally not stored on the hard drive but are kept in memory.
If an expiration time is set, the browser saves the cookie to the hard disk and then opens the browser again after it is closed, and the cookies remain valid until the set expiration time is exceeded. Some forums have the time to remember the login information for 1 months when you log in, which is to set the expiration time for the Cookie. At this point, even if we closed the browser, again open access to this forum will still be online status does not need to log in again.

Øsession

Unlike cookies, the user closes the browser session and is still saved on the server side, so long as the program sends out instructions to delete sessions, the server retains the conversation object until it is inactive beyond the set interval.

We sometimes misunderstand that the session has been deleted when the user closes the browser because most of the session mechanism uses cookies to hold the session ID, and the session ID disappears after the browser is closed, and the original SE is not found when connected to the server again. Ssion.

Øcache

Because of the cache mechanism we can clearly see that only power off the computer or let the program rewrite the cache. Otherwise this Cache will always be there.

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.