I understand the difference between localStorage and sessionStorage, but what is the difference between cookies vs local / session? Which has more security, advantages, etc.? Which one is better to use?
Greetings and thanks.
I understand the difference between localStorage and sessionStorage, but what is the difference between cookies vs local / session? Which has more security, advantages, etc.? Which one is better to use?
Greetings and thanks.
LocalStorage The information lasts until you clean cache and local information. You can store tons of information, obviously your browser will consume more memory. The security is from the browser itself, very strong to tell the truth.
Session Storage The information is stored until the browser or the tab is closed. You can store more information than a cookie.
Cookies They store little information and lasts the time you define them when creating them, one of the advantages is that the cookie can be easily grabbed in the front-end and in the back-end (without having to pass them through an AJAX for example if you want to use the information from the LocalStorage or SessionStorage, since only that information lives on the front-end) Security is limited, unless it is configured as httpsonly
Session Variables For my taste they are the best at the time of making Apps, the session variables are controlled and created by the back-end, here there is no JavaScript or browser involved. The security of these is linked to server security.
What would you use? In fact, it depends on what you want to achieve and develop.