The Sessions API gives administrators a live view of who is currently logged in to La Comanda. Rather than querying MySQL, the system persists session state to flat JSON files managed by the session controller. This approach keeps session tracking lightweight and avoids adding database load during high-activity service periods. Sessions that have been inactive for more than 30 minutes are automatically pruned the next time the active-sessions list is read.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JAQA20/LaComanda/llms.txt
Use this file to discover all available pages before exploring further.
Get Connected Users
GET /public/api/usuariosConectados.php
Returns an array of session objects representing every user who has been active within the last 30 minutes. Only accessible to accounts with rol_id = 1 (Admin).
Response Fields
The user’s database ID, matching the
id column in the usuarios table.The user’s full name (first and last name concatenated).
The user’s registered email address.
Human-readable role name:
Admin, Mesero, Cocina, or Barista.Timestamp of the user’s most recent login, formatted as
DD/MM/YYYY HH:MM AM/PM.Timestamp of the user’s most recent page request, used to compute the activity status label.
Detected device category and browser string, e.g.
"Desktop / Chrome" or "Mobile / Safari".Full URL of the last page the user navigated to, updated on every authenticated request.
IP address from which the user’s session originated.
Timestamp of the user’s last explicit logout, or the string
"Sin logout registrado" if the user has never clicked the logout button.Human-readable activity label based on time since
ultima_actividad. See Activity Status Thresholds.Bootstrap CSS utility classes applied to the status badge in the admin dashboard (e.g.
"badge bg-success", "badge bg-warning text-dark").Example Response
Example Request
Activity Status Thresholds
Theestado_label and estado_class fields are computed at read time by comparing ultima_actividad against the current server clock.
| Label | Condition | Bootstrap Class |
|---|---|---|
Activo ahora | Last activity ≤ 120 seconds ago | badge bg-success |
Inactivo reciente | Last activity 121 – 600 seconds ago | badge bg-warning text-dark |
Inactivo | Last activity > 600 seconds ago | badge bg-secondary |
Sessions with last activity older than 1 800 seconds (30 minutes) are not returned by this endpoint at all — they are pruned from the active-sessions store before the response is built.
Session Storage
Sessions are persisted to JSON files on the server filesystem, not in MySQL. This keeps the database schema simple and avoids locking issues during simultaneous order activity.| File | Purpose |
|---|---|
controller/sesiones_activas.json | Canonical store of currently active sessions. Keyed by PHP session ID. |
controller/sesiones_historial.json | Append-only log of all historical sessions including logged-out and pruned entries. |
listarActivas() is called (which happens on every request to usuariosConectados.php), any entry whose ultima_actividad is more than 1 800 seconds in the past is removed from sesiones_activas.json and written to sesiones_historial.json.