如何在两个不同的域中使用Cookie? [英] How do I use cookies across two different domains?

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

问题描述

我需要使用Cookie在两个不同的网域之间共享SSO信息,可以在PHP中完成,以及如何进行?

I need to share SSO information between two different domains with a cookie, can this be done in PHP and how?

推荐答案

在两个域上,放置从其他域拉取的图像或其他Web元素。使用网址通知其他网域用户X在域A上,并让域B将该用户ID与其系统上的该用户相关联。

On both domains, place an image or other web element that is pulled from the other domain. Use the URL to notify the other domain that user X is on domain A, and let domain B associate that user ID with that user on their system.

这有点复杂

Vinko在评论中指出(谢谢!),我不应该采取行动您理解您所了解的安全风险。如果此信息对任何人有任何价值,那么您应确保使用正确的加密,身份验证等,以避免发布敏感信息,并避免各种攻击(重放,中间人等)。这不应该太麻烦,因为你控制两个网站,你可以选择一个安全的密钥,两者,因为通信只通过这两个服务器通过这个特殊的URL。请牢记。

Vinko points out in a comment (thanks!) that I shouldn't take it for granted that you understand the security risks involved. If this information is of any value to anyone, then you should make sure you use proper encryption, authentication, etc to avoid releasing sensitive information and to avoid various attacks (replay, man in the middle, etc). This shouldn't be too onerous since you control both websites and you can select a secure secret key for both, since the communication is only going between the two servers via this special URL. Keep it in mind though.

- 亚当

这篇关于如何在两个不同的域中使用Cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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