Getting PHP session to work throughout website

Hi all,

On my userlogin.php I have used password_verify.
If the user logs in with matching details a session is started:

[php]
$rowdata = mysqli_fetch_array($result);

$firstName = $rowdata['firstName'];
$surname = $rowdata['surname'];
$securepassword = $rowdata['password'];
$username = $rowdata['userName'];

if(password_verify($password, $securepassword))
{
//start session
session_start();
$_SESSION[‘firstName’] = $firstName;
$_SESSION[‘surname’] = $surname;
$_SESSION[‘username’] = $username;
header(“Location: account.php”);
}
else
{
//redirect back to login form if not authorised
echo ‘Invalid username or password.’;
header(“refresh:5; url=login.html”);
exit;
}
[/php]

The code on my account.php page is:

[php]
// At the top -

<?php session_start(); ?>

// In the footer-

<?php echo $_SESSION['firstName']; ?>

[/php]

I don’t get any errors but it doesn’t echo the first name either.
Any help would be a help!

Thanks,
Jack

Managed to solve it, in my SQL statement I put firstname instead of firstName… oops! :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service