public function login(\row\database\Model $user) { $login = parent::login($user); extract($login); // extracts $login and $insert $login['user_id'] = $user->id; }
public function login(\row\database\Model $user) { $login = parent::login($user); extract($login); $login['user_id'] = $user->user_id; Session::$session['logins'][] = $login; $this->user = $user; $user->update(array('last_login' => time(), 'last_access' => time(), 'unicheck' => $login['unicheck'])); Session::success("You're now logged in..."); return true; }
/** * You can only log in a Model. Why? Consistency. * An authenticated user means a database record. That db record * should have a Model. The model shouldn't have a login method * because it knows nothing of the environment. */ public function login(\row\database\Model $user) { // In this case I use the base login method, but you don't have to. // You can put whatever you want in the database and/or session... $login = parent::login($user); extract($login); // Extracts arrays $login and $insert // Prepare session login layer $login['user_id'] = $user->user_id; // Add login to _SESSION Session::$session['logins'][] = $login; // isLoggedIn() for this HTTP request $this->save(array('user' => $user, 'salt' => $login['salt'])); return true; // Why would this ever be false?? }