如何使用JavaScript为其他域设置Cookie? [英] How to set a cookie for another domain using JavaScript?

查看:206
本文介绍了如何使用JavaScript为其他域设置Cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在一个域中设置cookie并在另一个域中访问它?

Is it possible to set cookie in one domain and access the same in another domain?

实际上,当用户单击时,我需要在A.com页面中设置cookie按钮,然后需要将用户重定向到B.com。但是Cookie只能在同一个域中使用,而不能在其他域中使用。

Actually I need to set a cookie in A.com page when user clicks a button and then user needs to be redirected to B.com. But the cookies are working for the same domain but not for other domain.

推荐答案

否。您只能为脚本当前正在运行的域设置cookie。

No. You can only set cookies for the domain your script is currently running on.

这篇关于如何使用JavaScript为其他域设置Cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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