PHP 会话安全

PHP sessions security

我不确定如何解释这一点,但基本上我希望用户导航到安装在我站点根目录下的 apache 服务器上名为 index.php 的文件。每当他们访问这个 URL 时,他们都会得到一个会话或 cookie,告诉我的服务器他们访问了这个站点,时间为 5 分钟。这会将他们重定向到另一个站点,例如 http://bing.com. Whenever they get redirected to the same index.php on my site, the session will be read and if it is present and hasn't expired, use echo to display an iframe element. If there is no session or it has expired, redirect to http://bing.com.

我自己也尝试过,但我太业余了。这是我的脚本:

<?php 
session_start(); 
if ((isset($_SESSION["visit"]) {
unset ($_SESSION['visit']);
echo "<p>Success</p><br><iframe src=secretpage.html width=100% height=95% frameBorder=0></iframe>"
}
 else {
    $_SESSION['visit']='true'; 
    header("Location: http://bing.com");
    die();
}
?> 

感谢您付出的时间和精力。

session_start();
if (isset($_SESSION['visit'])) {
    unset($_SESSION['visit']);
    echo '<p>Success</p><br><iframe src=secretpage.html width=100% height=95% frameBorder=0></iframe>';
} else {
    $_SESSION['visit']='true';
    header('Location: http://bing.com');
}