I am trying to develop a website and I am having issues with trying to hide information based on if a user is logged in.
I am using mysqli as a database and have registered a test user. Unfortunately, when using echo it doesn't change what is seen.
I have this in the header to create the session:
<?php
require 'includes/dbh.inc.php';
session_start();
?>
and then after that, I am using this in the index.php to try and show or hide based on if they are logged in:
<?php
if (!isset($_SESSION['userid'])) {
echo '<p class="login-status">You are logged in!</p>';
}
else {
echo '<p class="login-status">You are logged out!</p>';
}
?>
Regardless of what I seem to do it always displays "you are logged in!"