After I get the user data from the database, I should put it in Cookie or LocalStorage, which is faster to read locally?

this is the data I want to store. Is it better to store it in Cookie or LocalStorage?

{
  code:200,
  msg:"",
 "user_id": 3,
 "user_type": 2
  data:{
   expire:7200,    -sharp
   token:"9mzdDZXu3dENdFZQurfg0Vz8slgSgvvOAUebNFzyzcpQ5EnbxbF+hfG9DQkpUVQdh
        4p6HbQcAiz5RmuBAja1JJGgIdJI",       -sharptoken 
 }
}

Cookie is carried in HTTP headers every time. Does putting this data in Cookie cause performance problems?

Apr.05,2021

cookie consumes the server's bandwidth if your bandwidth is small, but the traffic is heavy.
if the traffic of general small websites is small, it doesn't matter.
one thing about putting cookie is that it can be obtained on the server side, and the cookie can be set and modified on the server side.
localstorage can only be modified on the client using js.


everything that does not need to be passed to the backend is put in the front-end cache (localStorage is a kind of front-end cache). All the things that need to be passed to the backend are put to cookie or passed to the backend through request parameters

.
Menu