I'm building a web-application and currently testing out how to retrieve values from the server database and display it on my page. My connection to my database is working just fine.
In my localhost, I run the code print_r($_SESSION['user'];
where $_SESSION['user']
stores the user's login session and it works fine. Here's what it outputs on my localhost:
Array([0]=>1 [1]=>Bob [2]=>Dylan [3]=>Bob.Dylan@gmail.com)
where Bob is the user's firstname
, Dylan is his lastname
, and Bob.Dylan@gmail.com is his email
.
So that's all good.
But when it comes to my live server and I run the same print_r($_SESSION['user'];
code again it displays absolutely nothing.
I'm eventually working my way to my objective of displaying all the related user's info on the database (basically, their profile page) so I thought I'd start with this and go from there but I can't even get the print_r
function to work correctly.
Can anyone help me?
EDIT:
- My connection to both my localhost and live server database is working fine
My code:
if(isset($_SESSION['user]))
{
print_r($_SESSION['user']);
}
else
{
echo "Session is not set"
}