Difference between session and cookie

the difference:

1. The data storage location is different:

The cookie data is stored on the client's browser, and the session data is stored on the server.
 

2. Different security levels:

Cookies are not very safe. Others can analyze the cookie stored locally and perform cookie spoofing. Considering the security, session should be used.
 

3. Different degrees of performance usage:

The session will be saved on the server for a certain period of time. When the number of visits increases, it will take up the performance of your server. In consideration of reducing the performance of the server, you should use cookies.

4. The data storage size is different:

The data saved by a single cookie cannot exceed 4K. Many browsers limit a site to save a maximum of 20 cookies, while the session is stored on the server side, and the browser has no restrictions on it.

5, the session mechanism is different

Session mechanism: The session mechanism is a server-side mechanism that uses a structure similar to a hash table (and possibly a hash table) to hold information.

Cookie session mechanism: A cookie is a small piece of text that a server stores on the local computer and is sent to the same server with every request. The web server sends the cookie to the client using HTTP headers. On the client terminal, the browser parses the cookies and saves them as a local file, which automatically binds any requests from the same server to these cookies.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324128176&siteId=291194637