这个登录脚本有什么问题?我有一个模态样式的 iframe 登录框,/login.php
我有一个/index.php
.
登录后,login.php 重定向到 index.php,但我没有看到用户名。只是Hello Guest
。当我尝试登录时,它说you, username, are already logged in
。
登录.php:
<?php session_start(); require_once('connections/Main.php');
if(isset($_SESSION['username'])) {
echo '<div class="error_message">Attention! You, '.$_SESSION['username'].' are already logged in.</div>';
echo "<br />";
echo "Go <a href='javascript:history.go(-1)'>back</a> to the page you were viewing before this.</li>";
exit();
}
?>
索引.php:
<?php session_start();
require_once('connections/Main.php');
?>
<div> Hello <?php if(isset($_SESSION['username'])) {
echo $_SESSION['username']; }
else{ echo 'Guest'; } ?></div>