Command: SESSION


Overview

The SESSION command returns the current session information for the authenticated client. It is typically used for diagnostics, auditing, or session lifecycle inspection.


Command Name

  SESSION
  

Description

Retrieves and returns the current session object associated with the client connection. This includes session metadata and user authentication details.


Syntax

  SESSION
  

This command takes no arguments. It must be executed from an active client connection that has previously authenticated.


Permissions

  • Requires a valid authenticated session.

  • Available to all authenticated roles (e.g., Admin, User).


Input Format

There are no input parameters or flags. It is a standalone command.

Example Input:
  localhost:9219> session
  

Output Format

The command returns a JSON-encoded object describing the session:

Output Fields:
Field Type Description
created_at string RFC3339 timestamp when the session was created.
last_accessed_at string RFC3339 timestamp of the last client activity.
session_id string Unique identifier of the session.
status int Session status (1 = active).
user object Authenticated user object.
user.Username string Username of the session owner.
user.Password string Redacted password (always masked).
user.Role string Role of the authenticated user (e.g., Admin).

Example Output

  Ok {
  "created_at": "2025-05-01T17:33:15.497273Z",
  "last_accessed_at": "2025-05-01T17:33:15.497273Z",
  "session_id": "8-127.0.0.1:53531",
  "status": 1,
  "user": {
    "Password": "*******",
    "Role": "Admin",
    "Username": "admin"
  }
}
  

Behavior on Error

  • If the client is not authenticated or the session is invalid:

      Error: unauthorized or session not found
      
  • If an internal server error occurs (e.g., session store failure):

      Error: internal server error
      

Use Cases

  • Validate that a session is correctly established.

  • Debug which user is currently authenticated.

  • View timestamp metadata for tracking or audit logging.

  • Confirm role-based access was properly set up post-login.