Reputation: 9
I am not getting any output from `" $_SESSION['name'] = $user_name;" or $_SESSION['email'] = $_POST['in_email'];`
It running on MariaDB. Seems I am missing something, try a good few things. But ran out of ideas. A hit or to would be appreciated.
if ($stmt = $link->prepare('SELECT user_id, user_password_hash, user_name FROM users WHERE user_email = ?')) {
$stmt->bind_param('s', $inemail);
$stmt->execute();
$stmt->store_result();
}
if ($stmt->num_rows > 0) {
$stmt->bind_result($user_id, $user_password_hash, $user_name);
$stmt->fetch();
if (password_verify($_POST['in_password'], $user_password_hash)) {
session_regenerate_id();
$_SESSION['loggedin'] = TRUE;
$_SESSION['email'] = $_POST['in_email'];
$_SESSION['id'] = $user_id;
$_SESSION['name'] = $user_name;
header("Location: ../index.php");
exit;
What am I overlooking ? Any hit would be appreciated.
Upvotes: 0
Views: 21
Reputation:
You need to make sure that you are running session_start();
This creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie.
https://www.php.net/manual/en/function.session-start.php
Upvotes: 1