Knowledgebase

Storing Data in the Browser Print

  • webdevelopment, database, woocommerce, security, performance, guide, howto, solution
  • 0

Client-side persistence.

WHAT OPTIONS EXIST

Simple key and value storage, persisting indefinitely The same, cleared when the session ends A structured database in the browser Cookies

WHAT EACH SUITS

  • Simple storage: small preferences and state
  • Session storage: state for one browsing session
  • The database: substantial structured data, offline work
  • Cookies: data the server also needs

WHY COOKIES ARE DIFFERENT

They are sent with every request, which affects performance and has security implications.

WHAT TO NEVER STORE IN THE BROWSER

Secrets Sensitive personal data Anything you rely on being unmodified

WHY

It is visible and editable by the user, and readable by any script on the page.

WHAT TO ASSUME

That anything stored may be absent, cleared or full.

WHAT TO DO ABOUT THAT

Handle failure, and function without it.

WHAT TO BE AWARE OF

Storage limits, which vary Private browsing modes, where it may not persist Users clearing it

WHAT TO USE IT FOR

Conveniences, not for anything that must not be lost.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot