PHP Code:
private function check_login() {
if(isset($_SESSION['user_id'])) {
$this->user_id = $_SESSION['user_id'];
$this->logged_in = true;
} else {
unset($this->user_id);
$this->logged_in = false;
}
If !isset($_SESSION['userid']) you destroy $this->user_id.
Then in you're login script:
PHP Code:
if($find_user) {
$session->login(User::$user);
}
chains back to session here:
PHP Code:
public function login($user) {
if($user) {
$this->user_id = $_SESSION['user_id'] = $this->user_id;
$this->logged_in = true;
}
}
And its toast. Not sure why you're chaining $this->user_id = $_SESSION['user_id'] = $this->user_id. It sorta doesn't make sense to set the same variable twice.
Solution, don't unset you're user_id, but set it to null.