Yve*_*Lee 5 php cookies iframe session session-cookies
我在不同的服务器上有两个域。第一个服务器的一个页面有一个 iframe 指向另一个服务器中的 url。我无法与 seesions 一起工作。
iFrame 页面代码(main.php):
<!DOCTYPE html>
<html>
<head>
<base target="_parent">
</head>
<body>
<iframe src="http://192.168.1.10/index.php"</iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的 iFrame 页面 index.php 有一个启动会话的简单登录系统。因此,有一个按钮可以加载以下代码(process.php):
<?php
session_start();
$_SESSION['valid'] = true;
$_SESSION['timeout'] = time();
header('location:catalogue.php');
?>
Run Code Online (Sandbox Code Playgroud)
在我的 catalogue.php 和每个页面上,我有以下会话代码(check.php):
<?php
session_start();
if (isset($_SERVER['HTTP_REFERER'])) {
if ($_SERVER['HTTP_REFERER'] == "") {
unset($_SESSION['valid']);
unset($_SESSION['timeout']);
header('location:index.php');
}
} else {
unset($_SESSION['valid']);
unset($_SESSION['timeout']);
header('location:index.php');
}
if (isset($_SESSION['valid'])) {
$timeout = $_SESSION['timeout'];
$time = time();
$t = $time - $timeout;
if ($t > 9000) { //15*60 = 900 Second, timeout to logout
unset($_SESSION['valid']);
unset($_SESSION['timeout']);
header('location:index.php');
} else {
$_SESSION['timeout'] = time();
}
} else {
header('location:index.php');
}
?>
Run Code Online (Sandbox Code Playgroud)
所以我有以下几点:
Button press On load it check session
to log in using check.php
index.php ==============> process.php ===============> catalogue.php
Run Code Online (Sandbox Code Playgroud)
我正在使用 iframe 来隐藏我的网络应用程序的真实 url 和更用户友好的域名。
我的问题:
** 更新 ** 经过一些测试,我认为会话没有开始(check.php)。它会else
在底部。我有公共服务器和本地服务器。
在main.php
没有任何会话代码。只有 iframe 中的页面有。该index.php
没有。如果用户按下登录以加载process.php
(启动会话)并重定向到catalogue.php
.
Catalogue.php
和我的应用程序的所有页面,都有一个check.php
用于检查会话的代码()。
我认为您的会话被 阻止SameSite by default cookies
。
\n\n将未指定 SameSite 属性的 cookie 视为\nSameSite=Lax。站点必须指定 SameSite=None 才能启用\n第三方使用。\xe2\x80\x93 Mac、Windows、Linux、Chrome 操作系统、Android
\n
尝试这个来检验我的理论。
\nchrome://flags/
通过地址栏访问SameSite by default cookies
SameSite by default cookies
标志 归档时间: |
|
查看次数: |
423 次 |
最近记录: |