我在不同服务器上有两个域名。第一个服务器的一个页面包含了一个iframe,指向另一个服务器上的URL。我无法管理会话。
iFrame页面代码(main.php):
<!DOCTYPE html>
<html>
<head>
<base target="_parent">
</head>
<body>
<iframe src="http://192.168.1.10/index.php"</iframe>
</body>
</html>
我的iFrame页面index.php有一个简单的登录系统,它会启动session。因此,有一个按钮加载以下代码(process.php):
<?php
session_start();
$_SESSION['valid'] = true;
$_SESSION['timeout'] = time();
header('location:catalogue.php');
?>
在我的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');
}
?>
我有以下内容:
Button press On load it check session
to log in using check.php
index.php ==============> process.php ===============> catalogue.php
我使用 iframe 来隐藏我的 web 应用的真实 URL 并使用更加用户友好的域名。
我的问题:
- 每次我在 index.php 中按下登录按钮时,它会重定向到 index.php 而不是 catalogue.php。 - 我能否隐藏 / 屏蔽 iframe 中的 URL 以避免被机器人 / 蜘蛛爬取。 - 欢迎任何建议 / 想法以实现更好的设置。
**更新** 经过一些测试,我认为会话没有启动(check.php)。它会到达底部的else。我有公共服务器和本地服务器。
main.php 没有任何会话代码。只有 iframe 中的页面有会话代码。index.php 没有。如果用户按下登录以加载 process.php(它开始会话)并重定向到 catalogue.php。我的应用程序所有页面都有一个用于检查会话的代码(check.php)。
http://192.168.1.10/index.php
它可以正常工作。当然,我是在我的本地网络中测试它。我正在尝试使用一个域名来隐藏本地 URL,以避免用户看到。 - YvetteLee