Session Token

Retrieves the session token generated after successful license validation.

Session tokens are created automatically when ValidateKey() succeeds.

Signature

std::string GetSessionToken() const;

Parameters

None - This function takes no parameters.

Returns

Type: std::string

Value
Description

Non-empty string

Valid session token

Empty string

No active session (not authenticated)

Description

The session token is a JWT (JSON Web Token) that represents an authenticated session. It is:

  • Generated by the server after successful license validation

  • Stored internally by the library

  • Used for subsequent authenticated requests

  • Time-limited (expires after period of inactivity)

Basic Example

Use Cases

Session Token Format

The session token is a JWT with the following structure:

Session Lifecycle

1

Token Creation

  • User calls ValidateKey(licenseKey)

  • Server validates license

  • Server generates JWT token

  • Token is returned and stored internally

2

Token Storage

  • Token is stored in memory by the library

  • Retrieved with GetSessionToken()

  • Not persisted to disk automatically

3

Token Expiration

  • Tokens expire after period of inactivity

  • Default expiration: 24 hours

  • Expired tokens require re-validation

4

Token Renewal

To renew an expired token:

Checking Session Status

Security Considerations

  • Do not store tokens in plain text files

  • Do not log tokens in production

  • Clear tokens on application exit

Error Handling

Best Practices

Example: Session Manager

Last updated