I am getting some unexpected errors on some code which has been working for a few weeks. I haven't changed this code yet I'm getting two errors upon logging in.
session_name(): Cannot change session name when session is active in /opt/lampp/htdocs/FantasyKicks/index.php on line 5
session_start(): A session had already been started - ignoring in /opt/lampp/htdocs/FantasyKicks/index.php on line 7
I have tried running session_destroy() to put me back on the login page and delete the session and then taking that line out and logging back in, but both errors still appears. I am wondering if there is actually an issue with how I've coded the logging in process or not.
login.php (i've taken out some irrelevant code on this page)
session_name('FantasyKicks');
session_start();
if(!$email & !$password) {
echo "All fields required";
} else {
if(!$email) {
echo "Email required";
} else {
if(!$password) {
echo "Password required";
} else {
if($num == 0) {
echo "Incorrect email or password";
} else {
// User is logged in
echo "LoggedIn";
$_SESSION['UserID'] = $user['UserID'];
$_SESSION['Email'] = $user['Email'];
$_SESSION['FirstName'] = $user['FirstName'];
$_SESSION['LastName'] = $user['LastName'];
$_SESSION['logged_in'] = true;
}
}
}
}
index.php (start of index.php)
require 'fkdb.php'; // Connect to database which uses XML config file
session_name('FantasyKicks');
session_start();
if (!isset($_SESSION['logged_in'])) {
$_SESSION['logged_in'] = false;
};