在两个网站之间共享Cookie [英] Share a cookie between two websites

查看:156
本文介绍了在两个网站之间共享Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个网站(A),该网站登录并从一个独立的网络服务中检索客户数据。

I have built a website (A) which logs in to and retrieves customer data from a separate web service.

拥有(A)的组织也有网站(B)具有网络形式。他们希望(A)上的登录客户能够点击(B),并查看预填充表单及其详细信息。

The organisation that owns (A) also has a website (B) which has a web form. They want a logged in customer on (A) to be able to click across to (B) and see a pre-populated form with their details.

这意味着)必须将其客户ID写入一个cookie,(B)可以读取,然后(B)可以从Web服务请求数据,并预填充表单。

This means (A) must write their customer ID to a cookie, which (B) can read, and then (B) can request the data from the web service, and pre-populate the form.

这会产生两个问题:


  1. 网站(B)可以读取网站(A)的Cookie吗?

  1. Can website (B) read the cookie for website (A)?

如果是这样,为了防止某人编辑cookie并在表单中看到其他人的数据,我需要对(A)

If so, to prevent someone from editing a cookie and seeing other people's data in the form, I would need to do something like encrypt the cookie on (A) and then have that decrypted in (B) - any suggestions along this line?

我无法将现有的登录信息更改为OAuth或其他网站,因为网络服务被其他几个网站使用,因此不能更改。

I can't change the existing login to OAuth or something, as the web service is consumed by several other sites, so this cannot change.

推荐答案

否。网站B无法从网站A读取Cookie。

No. Website B can't read a cookie from website A.

最简单的解决方法是将登录/凭据信息从网站A传递到网站B,并设置网站B设置一个独立的cookie。例如,登录网站A后,您可以使用加密的查询字符串快速重定向到网站B.网站B随后可以读取信息,设置自己的Cookie,并将用户重定向回网站A。

The easiest work-around is to pass login/credential information from website A to website B and have website B set a seperate cookie. For example, after logging into website A you could have them quickly redirected to website B with an encrypted querystring. Website B could then read the information, set its own cookie, and redirect the user back to site A.

这很麻烦,但可能。

这篇关于在两个网站之间共享Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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