Hello,
I've created a login script:
index.php
<?
session_start();
if (!isset($_SESSION['username']))
{
$username = trim($_POST["username"]);
$userpass = trim($_POST["userpass"]);
$submit = trim($_POST["submit"]);
if ((!empty($submit)) && (!empty($username)) && (!empty($userpass))
{
if (($username == "admin") && ($userpass == "admin"))
{
$_SESSION['username'] = $username;
echo <<<END
<script>
location.href="index.php?action=main";
</script>
END;
}
else
{
echo <<<END
<html>
<body>
<form action="index.php" method=POST>
<input type="text" name="userpass" value="$userpass">
<input type="password" name="userpass">
<input type="submit" name="submit">
</form>
</body>
</html>
END;
}
}
}
else
{
$action = trim($_POST["action"]);
if ($action == "main")
{
echo "Secured Page <a href=\"index.php?action=logout\">Logout</a>";
}
elseif ($action == "logout")
{
$_SESSION['username'] = array();
session_unset();
session_destroy();
echo <<<END
<script>
location.href="index.php";
</script>
END;
}
}
?>
The problem rise when I logout. The script returns me to the login form. I press "Back" button in IE. Browser asks me if I would like to refresh page. If Yes, then it shows me "Secured page". I don't know what to do...
I've tried:
1) To experiment with header:
html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires">
<meta http-equiv="Cache-Control" content="no-cache">
2) Disable cookies, but then doesn't work IE;
Help me, please...