This question already has an answer here:
I have been using the following code for beginning sessions, but I can't show the username after 'welcome'. How can I do that? I am using email and id for logging in. The email, id and username are stored in MySQL. Also when logged in, the login button should disappear, and the logout button should appear.
<div class="hello">
<?php
session_start();
require_once("config.php");
if (!(isset($_SESSION['login']) && $_SESSION['login'] != ''))
{
header ("Location: login.html");
exit;
}
else
{
echo "Welcome </b>, <a href=logout.php>Logout</a> <br><br>";
}
?>
</div>
</div>