html - Comunication betwen two *.php -
i have login.php , register.php. in header.php can see loged user. can not find way how logout.
next server.php
if (isset($_get['logout'])){ session_destroy(); unset($_session['username']); header("location:homepage.php"); }
and next header.php have
<!doctype html> <?php include('server.php'); ?> <?php if (isset($_session['username'])): ?> <p> welcome <?php echo $_session['username']; ?></p> <a href="homepage.php?logout='1'">logout</a> <?php endif ?> <?php if (!isset($_session['username'])): ?> <p><?php echo "you not loged" ?></p> <?php endif ?>
and looking find way "you not loged". , no success.
what missing?
you passing lowercase 'logout' checking sentence case 'logout' in $_get['logout']
if (isset($_get['logout'])){ session_destroy(); unset($_session['username']); header("location:homepage.php"); }
also need session_start() in php files @riggsfolly suggested.
Comments
Post a Comment