-1

I am going to build an application, which will use ajax to retrieve data and display it to the user. I want to use web storage but I dont know if I should use local storage or session storage? I know that with session storage, data gets lost when the browser is closed. Would this also be data which is stored in the web storage to be displayed to the user? Can anyone advise which storage is best for me as I am a bit confused.....

Thanks

nad
  • 17
  • 4

3 Answers3

-1

Check this answer: https://stackoverflow.com/a/19869560/4306983 It will help you understand which one to use depending in the context

-1

A lot of it depends on what you are trying to store. If it is not sensitive and can be persisted for a long time, I prefer using cookies. On the other end of the spectrum, if it is sensitive information that you don't want to allow the user to tamper with, use session storage. Local storage is very similar to session storage, but can persist for longer. Here is a much more in-depth answer to a similar question:

Local Storage vs. Session Storage vs. Cookies

hhoburg
  • 373
  • 2
  • 10
-1

sessionStorage is similar to localStorage;

the difference is that while data in localStorage doesn't expire, data in sessionStorage is cleared when the page session ends. Whenever a document is loaded in a particular tab in the browser, a unique page session gets created and assigned to that particular tab.

lejlun
  • 4,140
  • 2
  • 15
  • 31
rahat
  • 1
  • 2