log_user_in()

public function log_user_in(string $username, int $remember): void

Description

Logs a user in by generating an authentication token and storing it in the database. Handles both web and MX (Trongate MX/API) request types.

After successful login, resets failed login counters and lockout information, then redirects to the dashboard home.

For MX requests, returns the token as a plain text response rather than redirecting.

Parameters

ParameterTypeDescription
$usernamestringThe username to authenticate and log in.
$rememberint0 for session‑only login, 1 for persistent cookie (30 days).

Return Value

TypeDescription
voidRedirects on success or terminates with 500 error on failure.

Example Usage