Cookie is basically a string containing multiple fields. Cookies can be disabled on the client and expire.
1. Cookie data is stored in the client's browser, and session data is stored on the server.
2. Cookies are not safe. Others can analyze the Cookies stored locally and perform cookie spoofing.
Session should be used for security consideration.
3. The session will be stored on the server for a certain period of time. When the number of accesses increases, it will occupy the performance of your server.
Cookie should be used in consideration of reducing server performance.
4. data stored in a single cookie cannot exceed 4 kb. Many browsers limit that a site can store up to 20 cookies.
5. Personal suggestions:
Store important information such as login information as session
Other information can be stored in the cookie if it needs to be retained.
Differences between cookie and Session: