使用javascript使用两个不同的域设置和读取Cookie [英] Set and read cookies using two different domain using javascript

查看:1004
本文介绍了使用javascript使用两个不同的域设置和读取Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用javascript [document.cookie]在网址(如salesforce起始页网址)中设置Cookie,并在同一浏览器中使用javacript获取这些Cookie,但无法获取。



其实我的Apex页面,我加载在iframe,那时我设置的cookies,并获得这些cookie在另一个页面,在Salesforce域外。


解决方案

不可能读取Cookie由于安全原因由另一个域创建。我也相信浏览器处理的cookie的域方面的创建,所以我不相信可以创建一个cookie从另一个域。



我不要认为您所要求的是可能在单独的域(子域将工作)


I want to set cookies in url like salesforce apex page url using javascript[document.cookie] and get those cookies in another domain in same browser.using javacript but not able to get.

Actually my Apex page which i load in iframe and that time i set that cookies and get those cookies in another page which is out side of salesforce domain.

Any body have any idea how to set and get cookies using different domains.

解决方案

It isn't possible to read cookies created by another domain for security reasons. I also believe the browser handles the creation of the domain aspect of the cookie, so I don't believe it's possible to create a cookie "from" another domain.

I don't think what you're asking is possible on separate domains (sub-domains would work)

这篇关于使用javascript使用两个不同的域设置和读取Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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