Page 1 - index.php
The page starts with:
include_once('config.php');
include (DIR_INCLUDE.'basicHeader.inc.php');
include (DIR_INCLUDE.'init.php');
and my form which calls for authentication.php
Page 2 - authentication.php
session_start();
header("Cache-control: private"); // IE6 fix
include_once('config.php');
include (DIR_INCLUDE.'basicHeader.inc.php');
include (DIR_INCLUDE.'init.php');
Here I check if the username and password is valid. IF it is valid, I set some session variables.
$_SESSION['_userID'] = $row['empID'];
$_SESSION['_username'] = $row['empFname'].' '.$row['empLname'];
$_SESSION['_totalCalls'] = $row['totalCalls'];
$_SESSION['_totalSales'] = $row['totalSales'];
At this point, I can write:
echo 'USER NAME:'.$SESSION['username'];
This will output the user First name and Last name.
I removed the 'window.location="'.DIR_HTTP_ROOT.'main.php"'; and replaced it with a simple HREF link:
echo '<a href="main.php"> CLICK </a>';
Page 3 - main.php
Here is the start of the page:
session_start();
header("Cache-control: private"); // IE6 fix
include_once('config.php');
include (DIR_INCLUDE.'basicHeader.inc.php');
include (DIR_INCLUDE.'init.php');
echo 'USER NAME:'.$_SESSION['_username'];
With the same output as in Page 2, but the session variable is blank :-( I use session_start() on every page except the index page. And I don't reset any session variables....
😕