What is wrong with this login script? I have a modal-style iframe login box which is /login.php and I have a /index.php.
After logging in, the login.php redirects to the index.php, but I don’t see the username. just Hello Guest. When I try to login it says you, username, are already logged in.
login.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();
}
?>
index.php:
<?php session_start();
require_once('connections/Main.php');
?>
<div> Hello <?php if(isset($_SESSION['username'])) {
echo $_SESSION['username']; }
else{ echo 'Guest'; } ?></div>
start your session with this.
index.php