Represents an active user session in Lime CRM.

The Session object contains comprehensive information about the current user's authenticated session, including login details, enabled features, administrative privileges, and session timing. This information is crucial for security, feature availability, and session management.

Example

// Access session information in a component
const appRepo = platform.get(PlatformServiceName.Application);
const session = appRepo.getSession();

if (session?.active) {
console.log(`Logged in at: ${session.loginTime}`);
console.log(`Admin privileges: ${session.admin}`);

// Check session expiration
const expiresAt = new Date(session.expirationTime);
const now = new Date();
const minutesRemaining = (expiresAt.getTime() - now.getTime()) / 60000;

if (minutesRemaining < 5) {
// Warn about imminent session expiration
console.warn('Session expires in less than 5 minutes');
}
}

Example

// Check for enabled features and addons
const session = appRepo.getSession();

// Check feature flags
if (session?.features?.['advancedReporting']) {
// Enable advanced reporting features
}

// Check for specific addons
if (session?.addons?.['salesAutomation']) {
// Show sales automation tools
}

Hierarchy

  • Session

Properties

active: boolean

Indicates whether the session is currently active.

An active session means the user is authenticated and can perform operations. Sessions become inactive after logout or timeout.

addons: Record<string, any>

Configuration and state of enabled addons/plugins.

Contains a key-value map of addon names to their configuration objects. The structure of each addon's configuration depends on the addon itself.

admin: boolean

Indicates whether the user has administrative privileges.

Admin users typically have access to system configuration, user management, and other administrative features not available to regular users.

apm: Record<string, unknown>

Application Performance Monitoring (APM) configuration.

Contains settings for performance tracking and monitoring tools. The exact structure depends on the APM provider being used.

application: string

The name of the Lime CRM application.

Identifies which application/database the user is connected to.

database: string

The name of the underlying database.

Technical database identifier, usually matching the application name but may differ in some configurations.

displayName: string

User-friendly display name for the application.

This is the name shown in the UI, which may be different from the technical application name. Often includes company or department name.

expirationTime?: string

ISO 8601 timestamp when the session will expire.

After this time, the session becomes invalid and the user must re-authenticate.

features: Record<string, boolean>

Feature flags controlling available functionality.

A key-value map where keys are feature names and values indicate whether the feature is enabled.

id: string

Unique identifier for this session.

Used for session tracking, logging, and debugging. Each login creates a new session with a unique ID.

loginTime: string

ISO 8601 timestamp when the user logged in.

Marks the start of the session.

logoutTime?: string

ISO 8601 timestamp when the user logged out.

Only present after the user has explicitly logged out. Not set for sessions that timeout.

serviceNumber?: number

Application service instance number.

sessionTimeout: number

Session timeout duration in seconds.

Indicates how long a session can be idle before it automatically expires. The actual expiration time is calculated from the last activity.

userId: number

The ID of the authenticated user.

References the User.id property. Used to identify which user owns this session.

workstation: string

Name or identifier of the user's workstation.

Typically the computer name or IP address from which the user logged in.