获取引用 URL - 来自 Paypal (HTTPS) 的访问者

2021-12-29 00:00:00 http-referer php paypal

您好,我正在尝试获取引荐来源网址,但是当访问者从 Paypal 访问该网站时它不起作用

Hi I'm trying to get the referrer url but it doesn't work when the visitor comes to the site from Paypal

$ref = $_SERVER['HTTP_REFERER'];
echo $ref;

如果访问者从 Paypal 登陆网站,是否有一种简单的方法可以获取 Paypal 网址?

Is there a simple way to get the paypal url if the visitor land on the site coming from Paypal ?

编辑和澄清:我不希望在 Paypal 站点上进行任何特殊设置(包括但不限于:IPN、设置返回 URL、付款数据传输或 Paypal 站点上的任何其他特殊设置)访问者从 Paypal 访问网站时的 URL 引用,无论交易状态如何(如果有).

Edit and Clarification: I'm not looking to have any special settings on the Paypal site (including but not limited to: IPN, set the return URL, Payment Data Transfer or any other special settings on the Paypal site) All that I'm looking is to get the URL referer when visitors come to the site from Paypal, regardles of the status of a transaction (if there was one).

正如 Bob 在手册中所指出的

As pointed by Bob from the manual

$_SERVER 是一个包含信息的数组,如标题、路径、和脚本位置.此数组中的 > 条目由网络服务器.不能保证每个 Web > 服务器都会提供其中任何一项;服务器可能会省略一些,或提供其他未列出的在这里.

$_SERVER is an array containing information such as headers, paths, and script locations. The >entries in this array are created by the web server. There is no guarantee that every web >server will provide any of these; servers may omit some, or provide others not listed here.

所以剩下的唯一问题是 - 如果没有在 paypal 网站上设置一些东西,是否有任何解决方法?

So the only question left is - Is there any workaround to this without set something on the paypal site ?

推荐答案

如果您的站点使用 HTTP(而非 HTTPS)而 PayPal 使用 HTTPS,则不会发送 Referrer!

In case your site uses HTTP (not HTTPS) and PayPal uses HTTPS, there is no Referrer being sent!

HTTP RFC - 15.1.3 在 URI 中编码敏感信息 状态:

客户端不应在(非安全)文件中包含 Referer 标头字段HTTP 请求,如果引用页面是使用安全的协议.

Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.

因此,获得 Referrer 的唯一方法是在您的网站上使用 HTTPS.

So the only way to get the Referrer is to use HTTPS on your site.

相关文章