Code: Select all
<?php
require_once("clsUser.php");
require_once("clsUserDB.php");
$strUsername = $_POST['txtUsername'];
$strPassword = $_POST['txtPassword'];
#creating the database object.
$objUserDB = new clsUserDB;
#creating a user object, and setting it equal to the object returned by the function GetUserData.
$objUser = $objUserDB->GetUserData($strUsername);
if ($objUser->getPassword() == md5($strPassword)) {
#starts a session for the user.
[b]session_start();[/b]
#sets a session variable called username equal to the username they used to login.
[b]$_SESSION['username'] = $objUser->getUsername();[/b]
#redirect the user to the index page.
header('Location: index.php');
exit;
}
?>Code: Select all
<?php
session_start();
echo $_SESSION['username'];
?>Nothing is getting displayed on the test page. I have used
Code: Select all
echo $_SESSION['username'];Thanks!