I'm from the Netherlands and my English isn't perfect, but I will try my best.
My problem is as followed: I've made a local website with Wampserver and everything worked fine on it, but now I've bought hosting and my SESSION variable doesn't work anymore.
The code of the function:
public function login($uname,$umail,$upass)
{
try
{
$stmt = $this->db->prepare("SELECT * FROM users WHERE user_name=:uname OR user_email=:umail LIMIT 1");
$stmt->execute(array(':uname'=>$uname, ':umail'=>$umail));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() > 0)
{
if(password_verify($upass, $userRow['user_pass']))
{
$_SESSION["user_session"] = $userRow['user_id'];
return true;
}
else
{
return false;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
Code of the page where I try to check if someone is logged in:
if(!$user->is_loggedin())
{
$user->redirect('login.php');
}
$user_id = $_SESSION['user_session'];
And then the error I'm getting: Undefined index: user_session in /mnt/web515/b0/72/510494272/htdocs/admin/index.php on line 8
Can someone please help me figure out why user_session is undefined now but not when I locally run the website?
Thanks in advance!