PHPSession
PHPSession
Session based authentication adapter
This authentication adapter uses the session cache to store the user identity and token.
Configuration Directives
autologin.period - default: 1
This is the period in which the autologin cookie will remain active (ie: will expire after this many days). The default is one day.
autologin.hash - default: md5
This is the hash algorithm used to encrypt the token placed in the cookie in the user's browser session. This data is hashed to ensure that it can not be manipulated by the user.
token.hash - default: md5
The token hash is the value stored in the session cache and is used to confirm that a user account is authenticated. As an added security measure we apply a hash to this value so that plain test passwords will never be stored in the session cache, even if there is no password encryption chain.
timeout - default: 3600
For a standard login, this is the session expirey timeout. Basically this is the maximum time in which a session will ever be active. If autologin is being used, then it is quite common to set this to a low value to allow the user to be re-authenticated with the autologin token periodically.
Properties
sessionKey
private string $sessionKey = 'hazaar_auth_session'config
private array $configidentity
private string $identityMethods
__construct
public __construct(array $config): voidParameters
| Parameter | Type | Description |
|---|---|---|
$config | array |
isEmpty
public isEmpty(): boolload
Loads session data for the given token.
public load(string $token, ?array $sessionData): boolAttempts to set the session ID to the provided token and starts the session with specific options. If a timeout is configured, it sets the session garbage collection max lifetime accordingly. On successful session start, retrieves the session data for the configured session key.
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string | the session token to load |
$sessionData | array |
read
Reads and returns the session data associated with the current session key.
public read(): voidcreate
Creates a new session entry with the provided identity and data.
public create(string $identity, array $data): voidParameters
| Parameter | Type | Description |
|---|---|---|
$identity | string | the identity associated with the session |
$data | array |
has
Checks if a specific key exists in the current session.
public has(string $key): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | the session key to check for existence |
get
Retrieves a value from the session using the specified key.
public get(string $key): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | the key associated with the session value to retrieve |
set
public set(string $key, mixed $value): voidParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$value | mixed |
Unsets a value from the session data associated with the given key.
public (string $key): voidParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | the key of the session variable to unset |
clear
public clear(): voidgetToken
Retrieves the current PHP session ID token.
public getToken(): ?stringrefresh
Refreshes the session using the provided token.
public refresh(string $token): ?stringParameters
| Parameter | Type | Description |
|---|---|---|
$token | string | the session refresh token |
getIdentity
Retrieves the identity associated with the current session.
public getIdentity(): ?stringGenerated by Hazaar API Doc Generator on Sun, 01 Mar 2026 09:22:26 +0000