如何使用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.