Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the differences between cookies and session

Shulou Source: shulou.com Published: 2022-06-02 08:17:35 11月17日 Update

This article mainly introduces the differences between cookies and session, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

The cookies mechanism uses a scheme to keep the state on the client side.

The lifetime of 1.cookies is during the browser session, the browser is closed and the cookies disappears.

two。 Set the expiration date, cookies is saved on the hard drive (can be shared), close the browser cookie still exists

3.cookies is not very secure. Others can analyze the local cookies to cheat on cookies.

4. The data saved by a single cookies cannot exceed 4k, and many browsers limit a site to a maximum of 20 cookies

The session mechanism adopts the scheme of keeping the server in a state.

1.session will be saved on the server for a certain period of time, and when the number of visitors increases, it will consume the performance of the server.

Cookies should be used for performance

2.session is still better than cookies in terms of security.

The realization principle of session

1. When you create a session, the server generates a unique session and then uses it to generate a closed browser

Invalid cookies

two。 Then add a data item associated with the session to the hash table

3. When the browser is submitted to the server, the session information belonging to the user will be found in the hash table through session=123.

Thank you for reading this article carefully. I hope the article "what's the difference between cookies and session" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Browser browsing server service article security performance data solution is in mechanism state generation value information interest single principle at the same time customer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Microsoft macOS Shulou Technology Linux