What are the Web front-end technologies?What’s the difference between a Cookie and a Session?Cookies and Sessions are common techniques in Web applications that can be used to track a user’s entire Session. But what’s the difference between them?Next thousand front Xiaobian will give you a brief introduction.
The main purpose
Cookie is born to solve the problem that HTTP stateless characteristics can not meet the interactive Web, mainly used for session state management (such as user login status, shopping cart, game scores or other information to record); Personalization Settings (such as user-defined Settings, themes, etc.); Browser behavior tracking (e.g., tracking and analyzing user behavior).
Session is a mechanism used by the server to record the state of the client. It is simpler to use than Cookie, and it also increases the storage pressure of the server accordingly.
If the Cookie mechanism confirms the identity of the customer by checking the “pass” on the customer, then the Session mechanism confirms the identity of the customer by checking the “customer list” on the server. Session is equivalent to a client profile created by the program on the server. When the client visits, it only needs to query the client profile table.
Usage scenarios
Cookie technology can store information in different browsers, and can achieve multiple requests for data sharing, divided into temporary cookies and long-term cookies. If a Cookie has no expiry date set, the browser will delete the Cookie when it is closed. This Cookie is called a temporary Cookie. If a Cookie has an expiration date, then the browser will keep the Cookie until the expiration date. This Cookie is called a persistent Cookie.
Session is a communication state retention mechanism based on Cookie, which can store some information of a user on the server side. After creating a Session, the server returns the Session ID to the browser in the form of Cookie. If the browser is closed, it will carry the Session ID when visiting the server again. When the server finds that the browser brings the Session ID, it will use the corresponding Session in memory to serve it.
What is the relationship between a Cookie and a Session
If a Web front-end programmer is asked “What is the relationship between Cookie and Session?” during an interview, the answer is that both are produced for client-server interaction. Cookie writes the user’s data to the user’s browser, while Session technology writes the user’s data to the user’s own Session. A Session is an object, and its properties can be of any type (cookies can only be set as strings). Cookie is stored in the client side, the disadvantage is easy to forge, not secure, Session is stored in the server side, will consume server resources, Session implementation has two ways: Cookie and URL rewriting.
If you want to know more about cookies and sessions, or want to quickly advance to the front end of the Web, you can choose a major to learn, so that you can learn efficiently and quickly get employed.
The main purpose
Cookie is born to solve the problem that HTTP stateless characteristics can not meet the interactive Web, mainly used for session state management (such as user login status, shopping cart, game scores or other information to record); Personalization Settings (such as user-defined Settings, themes, etc.); Browser behavior tracking (e.g., tracking and analyzing user behavior).
Session is a mechanism used by the server to record the state of the client. It is simpler to use than Cookie, and it also increases the storage pressure of the server accordingly.
If the Cookie mechanism confirms the identity of the customer by checking the “pass” on the customer, then the Session mechanism confirms the identity of the customer by checking the “customer list” on the server. Session is equivalent to a client profile created by the program on the server. When the client visits, it only needs to query the client profile table.
Usage scenarios
Cookie technology can store information in different browsers, and can achieve multiple requests for data sharing, divided into temporary cookies and long-term cookies. If a Cookie has no expiry date set, the browser will delete the Cookie when it is closed. This Cookie is called a temporary Cookie. If a Cookie has an expiration date, then the browser will keep the Cookie until the expiration date. This Cookie is called a persistent Cookie.
Session is a communication state retention mechanism based on Cookie, which can store some information of a user on the server side. After creating a Session, the server returns the Session ID to the browser in the form of Cookie. If the browser is closed, it will carry the Session ID when visiting the server again. When the server finds that the browser brings the Session ID, it will use the corresponding Session in memory to serve it.
What is the relationship between a Cookie and a Session
If a Web front-end programmer is asked “What is the relationship between Cookie and Session?” during an interview, the answer is that both are produced for client-server interaction. Cookie writes the user’s data to the user’s browser, while Session technology writes the user’s data to the user’s own Session. A Session is an object, and its properties can be of any type (cookies can only be set as strings). Cookie is stored in the client side, the disadvantage is easy to forge, not secure, Session is stored in the server side, will consume server resources, Session implementation has two ways: Cookie and URL rewriting.
If you want to know more about cookies and sessions, or want to quickly advance to the front end of the Web, you can choose a major to learn, so that you can learn efficiently and quickly get employed.
Read More:
- Failed to set session cookie. Maybe you are using HTTP instead of HTTPS to access phpMyAdmin.
- Nginx front end and back end separation + service cluster reverse proxy
- The back end cannot receive the parameters passed by the front end
- Jsonformat annotation solves the problem of time format in the front end of localdatetime
- Decipher the evolutionary path of junior, middle and senior programmers (front end)
- The time of the time database displayed by the front end is inconsistent
- Nginx modifies the front end request size limit (413 request entity too large)
- Front end Vue project operation error module build failed
- Front end project construction error unexpected character ‘@’ solution
- Hide print button when printing page in front end
- Record a front end error net:: err_ HTTP2_ PROTOCOL_ ERROR 200
- Some uncommon problems and solutions of cookie
- Front end project runtime prompts syntax error: typeerror: token.type.endswith is not a function solution
- session_ start(): open(SESSION_ FILE, O_ Rdwr)) failed: processing of permission denied (13)
- can’t set headers after they are sent
- RPC principle and related technologies used
- Solution to cross domain sharing problem of session
- Three ways of adding cookie by scratch
- [Space] There are many right and wrong before and after, it can cause major failures, please see
- Cross origin requests are only supported for