In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is mainly about "what's the difference between session and cookie". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what's the difference between session and cookie?"
What's the difference between session and cookie?
Because HTTP is a stateless protocol, the server needs to record the status of users from time to time, so it needs to use some mechanism to identify specific users.
Session is a file similar to a hash table that exists on the server. It contains the information we need, and we can take it out when we need it. It can be thought of as a large map, in which the client sessionID is stored. When the user sends a request to the server, the user will take this sessionID with it and take out the corresponding value.
Session application scenario: when you click the "add shopping cart" button on a shopping site, because the HTTP protocol is stateless, you don't know which one is operated by the user, so you need to create a specific session for a specific user to identify and track the user, so that you know which items to put into the shopping cart, and this session is placed on the server side. There are many ways to save session on the server side, including memory, database, files and so on. When clustering, we should also consider the specificity of session. On large websites, there will also be a special cluster of session servers to save user sessions. At this time, session information is stored in memory, and some caching techniques are used to put session, such as Memcached.
Cookie application scenario: when logging in to a website, the next time you want the site to remember its own account, you need to set up a local cookie. Each time a HTTP request is made, the client sends the corresponding cookie information to the server. Most of them use cookie to implement session tracking, that is, when the session is created for the first time, the sessionID is recorded in the cookie. After that, the ID is sent to the server for each request, and the server knows what to deal with. If the browser disables cookie, the URL rewrite is required for session tracking, that is, every HTTP interaction, the URL will be appended to the above, such as parameters such as sid=123456, according to which the server can identify the user.
Cookie and session are generally considered to be two independent things. Session uses the method of keeping state on the server side, and the method of keeping state on the client side adopted by cookie. However, after cookie is disabled, session cannot be realized, because session uses sessionID to determine the server session corresponding to the current conversation, while sessionID is transmitted through cookie. If you disable cookie as opposed to losing sessionID, you will not be able to get session. At this point, you need to use URL or hidden form to pass sessionID.
At this point, I believe you have a deeper understanding of "what's the difference between session and cookie". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.