Skip to content

Get Session Information

Fetch the current authenticated user's session information.

Overview

The Session::current() method retrieves details about the currently authenticated user. If no valid session exists (i.e., the user is not logged in), the API returns a 404 error.

Usage

Basic Usage

Retrieve the current user's session information:

php
use ThingsTelemetry\Traccar\Facades\Session;

$user = Session::current();

With Token Verification

Optionally pass a token to verify its validity:

php
use ThingsTelemetry\Traccar\Facades\Session;

$token = 'abc123...';
$user = Session::current($token);

Result

The response is an instance of ThingsTelemetry\Traccar\Dto\UserData.

php
$user->id; // 42
$user->name; // "Jane Doe"
$user->email; // "jane@example.com"
$user->administrator; // true|false
$user->map->value; // "osm"
$user->coordinateFormat; // enum CoordinateFormat
$user->expirationTime?->toIso8601String();
$user->attributes->toArray(); // array<string, mixed>

Key Result Fields

  • idint - Unique user identifier
  • namestring - User's full name
  • emailstring - User's email address
  • administratorbool - Whether the user has admin privileges
  • mapMap - Preferred map provider
  • coordinateFormatCoordinateFormat - Preferred coordinate format
  • attributesUserAttributesData - Additional user attributes

IMPORTANT

Refer to the UserData DTO documentation for complete field documentation.

Released under the MIT License.