通过jQuery或PHP将变量从一个域传递到另一个域

时间:2015-09-16 17:18:58

标签: javascript php jquery ajax

我有两页,让我们说:

webpage1.com, and
webpage2.com

网页1包含

page.html - contains reference variables in accessing the proper data stored in webpage2.com. one reference variable may be stored in localStorage

网页2包含

page.html - contains the layout of the whole webpage
page.php - contains the information being worked at behind the scenes, also this guy should fetch the data i send from webpage1.

我知道你们可能会说像ajax这样的事情。但是webpage2已经在其插件上使用了AJAX功能(是的,网页2有我需要的插件),所以ajax已经不是我的选择了。我也试过在网址上传递一个字符串参数,但是当我尝试获取它时,webpage2的page.php就不会响应$ _GET。

我正在考虑类似于能够共享跨域的变量。例如跨域localStorage,或cookies,或$ _SESSION。

最后,网页1和网页2有不同的服务器。

我希望你们明白。感谢

1 个答案:

答案 0 :(得分:0)

为此简单使用数据库。

->喜欢使用mysqli_connect()将详细信息存储在webpage1.com的数据库中。
->然后使用mysqli_connect()从webpage2.com访问该数据库。
->然后,您可以删除那些条目,以节省数据库内存。

您可以在此处找到有关mysqli_connect()的更多信息
https://www.php.net/manual/en/function.mysqli-connect.php

注意:

mysqli_connect()的值应该相同,以便您可以检索数据库和 存储的数据。
有人说您可以通过URL传递变量,但是URL's可以在客户端进行编辑,这会损害您的数据。
或者,如果您使用的anit-ddos会修改URL,并且存储在URL上的数据将丢失。

相关问题