I am using an open source login repository from Github (https://github.com/panique/php-login-minimal) to create a login system for my website. The login process seems to be successful and the new user registrations are populating to my MySQL database, but when I try to echo session variables like the username it is just coming up blank.
Here's a sample code that doesn't show up:
<p>Hey, <?php echo $_SESSION['user_name']; ?>. You are logged in.</p>
and I have also tried this:
<p>Hey, <?php echo("{$_SESSION['user_name']}"); ?>. You are logged in.</p>
but to no avail. You can also see how this problem works on the live site at http://www.geneticgolf.com/views/logged_in.php .
Any help on what I'm doing wrong would be appreciated.
Ensure that at the top of the same page that has this code:
<p>Hey, <?php echo $_SESSION['user_name']; ?>. You are logged in.</p>
that you have (as the first instruction):
<?php
session_start();
If you have that correct, then try this:
<?php
session_start();
echo '<pre>'
echo $_SESSION;
echo '</pre>'
die();
At the least, that will tell you what is in your $_SESSION variable.
This post might be helpful to you in trying to solve your problem: