everyone I started the session variable at the top of the login.php page. the session is then set and I call the second page using the include statement. I tested with an if statement and it seemed to pass ok. then I try to echo the contents of the variable in the newly displayed page. The page displays meaning that it passes the if block but the contents of the session variable does not show. It's as if the session variable has gone out of scope. How can I access my session variable in a different page.
<?php
session_start();
$username = "";
if (isset($_POST['submit']))
{
$username = $_POST["username"];
$password = $_POST["password"];
$_SESSION["username"] = $found_admin["username"];
if (isset($_SESSION["username"]));
{
redirect_to("index.php");
}
else
{
$_SESSION["message"] = "Username/password not found.";
}
}
?>
<?php include("login.html"); ?>
Here's the html page that's called by my php file:
<!doctype html>
<head>
</head>
<body>
<?php
echo $_SESSION["username"];
$loggenOnUser=$_SESSION["username"];
?>
<div class="gridContainer clearfix">
<div id="div1" class="fluid">
This page is being called by my login.php file.</div><div id="LoggedInUser" class="fluid ">Hi. I'm <?php $loggenOnUser?> </div>
<img id="homeImage" src="images/home.gif" /> </div>
</div>
</body>
</html>
Can't seem to get why I can't get access to the session variable on another page. Any help would be greatly appreciated. Thanks!