localStorage的VS的sessionStorage VS饼干 [英] localStorage vs sessionStorage vs cookies
问题描述
我在一个应用程序,我需要用户在保留一些数据被记录在工作,我有一个问题,就是什么之间的差异
本地存储,sessionStorage的,饼干???
I am working in an app where I need to keep some data during the user is logged in and I have that question, what is the difference among localStorage, sessionStorage, cookies ???
我是问我能以坚持在DOM一些数据,即使用户刷新页面使用,有些人说:使用的sessionStorage或localStorage的话,有人想出了使用<一个想法HREF =https://docs.angularjs.org/api/ngCookies/service/$cookies> ngCookies ,因为它工作在每一个浏览器,但是,这是我应该使用?
I was asking what can I use in order to persist some data in the DOM, even if the user refresh the page, some people says: use sessionStorage, or localStorage, then, someone came up with the idea of use ngCookies because it works in every browser, but, which should I use ?
推荐答案
的localStorage 和的sessionStorage 都是所谓的 WebStorages 和特点HTML5。
localStorage and sessionStorage are both so-called WebStorages and features of HTML5.
的的localStorage 的存储信息,只要用户不删除它们。
localStorage stores information as long as the user does not delete them.
的的sessionStorage 的存储信息,只要该会话去。通常,直到用户关闭的标签/浏览器。
sessionStorage stores information as long as the session goes. Usually until the user closes the tab/browser.
饼干只是饼干,这是由旧的浏览器的支持,通常是使用框架后备上述 WebStorages
cookies are simply cookies, which are supported by older browsers and usually are a fallback for frameworks that use the above mentioned WebStorages.
在相反的Cookie可以存储方式更少的信息然后WebStorages和WebStorages的信息不会传送到服务器
In contrast cookies can store way less information then WebStorages and the information in WebStorages is never transferred to the server.
请记住,欧盟已经要求网站告知其用户有关的cookies的使用情况调节。我不知道这是否也适用于WebStorages
Keep in mind that the EU has a regulation that requires websites to inform their users about the usage of cookies. I dont know whether this also applies to WebStorages
这篇关于localStorage的VS的sessionStorage VS饼干的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!