{"id":207,"date":"2016-05-13T06:22:04","date_gmt":"2016-05-13T06:22:04","guid":{"rendered":"http:\/\/muthu.co\/?p=207"},"modified":"2021-01-02T14:06:02","modified_gmt":"2021-01-02T14:06:02","slug":"difference-between-localstorage-sessionstorage-and-cookies","status":"publish","type":"post","link":"http:\/\/write.muthu.co\/difference-between-localstorage-sessionstorage-and-cookies\/","title":{"rendered":"Difference between localStorage, sessionStorage and cookies"},"content":{"rendered":"
\"Different<\/a>
Different client side storage solutions. localStorage, sessionStorage and cookies<\/figcaption><\/figure>\n

localStorage<\/code>, sessionStorage<\/code> and cookies are all client storage solutions which store data as key\/value pairs in the browser. localStorage<\/code> and sessionStorage<\/code> both extend Storage. There is no difference between them except for the intended “non-persistence” of sessionStorage<\/code>.<\/p>\n

    \n
  • sessionStorage<\/code> maintains a separate storage area for each given origin that’s available for the duration of the page session (as long as the browser is open, including page reloads and restores)<\/li>\n
  • localStorage<\/code> does the same thing, but persists even when the browser is closed and reopened.<\/li>\n<\/ul>\n

    both the above storages can be accessed using global variables\u00a0sessionStorage<\/code> and localStorage<\/code><\/p>\n

    Cookie on the other hand is used to store data that has to be sent back to the server with subsequent requests. \u00a0Cookies are primarily for reading server-side, localStorage<\/code> and sessionStorage<\/code> can only be read on the client-side. <\/p>\n","protected":false},"excerpt":{"rendered":"

    localStorage, sessionStorage and cookies are all client storage solutions which store data as key\/value pairs in the browser. localStorage and sessionStorage both extend Storage. There is no difference between them except for the intended “non-persistence” of sessionStorage. sessionStorage maintains a separate storage area for each given origin that’s available for the duration of the page […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[52],"_links":{"self":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/207"}],"collection":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":1,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":1652,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/posts\/207\/revisions\/1652"}],"wp:attachment":[{"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/write.muthu.co\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}