/** * @param $username string * @param $password string * @param $sessionOnly boolean * @return User */ public static function login($username, $password) { $user = User::login($username, $password); if (!$user) { return null; } // don't log premade users in, just return success. if ($user->premade) { return $user; } // keep the user logged in for 15 minutes $expireTime = time() + 15 * 60; $session = UserSession::createForUser($user, $expireTime); // set the cookie to expire when the browser session ends Session::setSessionCookie($session->token, 0); return $user; }