在AngularJS会话存储,本地存储和饼干之间的区别 [英] Difference between Session Storage, Local Storage and Cookies in AngularJS

查看:722
本文介绍了在AngularJS会话存储,本地存储和饼干之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想挖成角,为此,我想知道会话存储,本地存储和饼干之间的区别。

I would like to dig down into Angular, and for that i would like to know the difference between Session Storage, Local Storage and Cookies.

问题的问题---

1)$ windows.sessionStorage可以用来存储用户会话,但它存在的问题是,当你在新标签中打开它的东西再次要求用户登录。

1) $windows.sessionStorage can be used to store user session but the problem with it is, when you open something in a new tab it again ask the user to login.

2)将本地存储将是问题的问题1的解决方案?如果是这样,这是否意味着我需要本地存储和会话存储无论是在我的应用程序或本地存储将作为会话存储。

2) Will Local Storage would be a solution to problem question 1 ? and if so, does that mean i need local storage and session storage both in my app or local storage will act as session storage as well.

3)我也在努力记住我的登录表单上 - 它是安全存储用户的密码和电子邮件在本地存储这一点,如果没有什么是做记得我的角度最好的方式。

3) I am also working on Remember me on my login form - is it safe to store password and email of the user in the local storage for this, if not what is best way to do remember me in angular

4)Cookies是伟大的,但企业的公司让他们在那里浏览器?

4) Cookies are great, but does corporate companies allow them on there browser?

希望能找到像样的答案

感谢

推荐答案

1)这是正确的的sessionStorage 是暂时的,它被设计这样做。

1) It is correct that sessionStorage is temporary, and it has been designed to do so.

2)本地存储将解决登录与被打开一个新的浏览器会话或等待很长一段时间后消失的问题,但没有,的localStorage 将不会采取行动作为浏览器请求的会话cookie。

2) Local storage will solve the issue of the login going away with a new browser session being opened or after waiting a long time, but no, localStorage will not act as a session cookie for browser requests.

3)许多不同的服务器端应用程序支持加密和防篡改的应用cookie支持。话虽这么说,它始终是最好不要用户密码存储在客户端,也许令牌也许您的服务器会识别并能够解密/解code和查找正确的用户记录。

3) Many different server side applications support encryption and tamper-resistant cookie support for applications. That being said, it is always best not to store user passwords in the client, maybe a token perhaps that your server will recognize and be able to decrypt/decode and look up the correct user record.

4)我想说的是现在,饼干被普遍接受的是安全的,然而,始终是一种可能性,并根据您的客户或观众你可能有一个问题存在。此外,如果cookie是在浏览器中禁用会议将无法正常工作。 (虽然我对这个前景是普通人群的猜测,即:不可以引用我这句话)

4) I would say nowadays yes, cookies are generally accepted to be safe, however that is always a possibility, and depending on your clients or audience you may have an issue there. Also sessions won't work if cookies are disabled in the browser. (Though my outlook on this is speculation on a general population, ie: don't quote me on that)

我对你的需求的建议是,当用户遇到页面设置会话变量。然后将结果保存在localStorage的或用一个cookie,然后当用户返回到会议结束后的应用程序已经死了,有一些架构设置重新进行身份验证并自动重新分配会话。

My recommendation for your needs is to set a session variable when the user encounters the page. Then store the result in localStorage or with a cookie, and then when the user returns to the application after the session has died, have some architecture set up to re-authenticate and re-assign the session automatically.

希望这有助于!

编辑:会话Cookie 的是浏览器标签之间的同一个窗口中共享。但是的会话存储的已经指出并非如此。

Session Cookies are shared between browser tabs within the same window. However Session Storage has been pointed out not to be.

这篇关于在AngularJS会话存储,本地存储和饼干之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆