JavaScript中的Cookie [英] Cookies in javascript
本文介绍了JavaScript中的Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在javascript中创建的Cookie无法在另一个项目中的ts文件中访问。如何创建一个可以访问所有项目的cookie。
谢谢
我是什么尝试过:
尝试过document.cookie和$ .cookie
Cookie created in javascript not accesable in ts file which is in another project. How can create a cookie that is accesable to all projects.
Thanks
What I have tried:
Tried document.cookie and $.cookie
推荐答案
.cookie
Projects是一个仅存在于开发IDE中的概念,它们与代码如何作为网站无关。
假设您将不同项目的代码放在不同的网站上,出于安全原因,您无法共享Cookie,这就是互联网的运作方式。您是否希望恶意网站访问您用于向您的银行验证的Cookie?
您可以共享Cookie的唯一方法是,如果这些网站位于彼此的子域中。所以;
site1.project.com
可以用
$ b $分享cookies b
site2.project.com
"Projects" are a concept that only exist in the development IDE, they have no relevance to how the code functions as a website.
Assuming you are putting the code from your different projects on different websites, you can't share cookies for security reasons, that's how the internet works. Would you want a malicious site accessing the cookies you use to authenticate with your bank?
The only way you can share cookies is if the sites are on subdomains of each other. So;
site1.project.com
could share cookies with
site2.project.com
这篇关于JavaScript中的Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文