What is the difference between cookies, sessionStorage and localStorage?

  • A cookie is a website to indicate the user identity and data stored on the user's local terminal (Client Side) are (usually encrypted)

  • cookie data always carries (even if not required) at http request homologous, the record will be passed back and forth between the browser and the server

  • sessionStorageAnd localStoragedoes not automatically send data to a server, save only in the local

  • Storage size:

    • cookie data size can not exceed 4k
    • sessionStorageAnd localStoragealthough there are storage size limit, but much larger than the cookie, you can reach 5M or greater
  • There Time:

    • localStorage To store persistent data, after the browser is closed automatically deleted unless the data is not lost data
    • sessionStorage Data is automatically deleted after the current browser window is closed
    • Valid until the expiration date cookie cookie settings, even if the window or browser is closed

Guess you like

Origin www.cnblogs.com/r-mp/p/11293735.html