Psr16SessionStore implements SessionStoreInterface
PSR-16 compliant cache-based session store.
This implementation uses any PSR-16 compliant cache as the storage backend for session data. Each session is stored with a prefixed key using the session ID.
Tags
Table of Contents
Interfaces
Properties
Methods
- __construct() : mixed
- destroy() : bool
- Destroy a session.
- exists() : bool
- Check if a session exists.
- gc() : array<string|int, Uuid>
- Cleanup old sessions Sessions that have not updated for the configured TTL will be removed.
- read() : string|false
- Read session data.
- write() : bool
- Write session data.
- getKey() : string
Properties
$cache read-only
private
CacheInterface
$cache
$prefix read-only
private
string
$prefix
= 'mcp-'
$ttl read-only
private
int
$ttl
= 3600
Methods
__construct()
public
__construct(CacheInterface $cache[, string $prefix = 'mcp-' ][, int $ttl = 3600 ]) : mixed
Parameters
- $cache : CacheInterface
- $prefix : string = 'mcp-'
- $ttl : int = 3600
destroy()
Destroy a session.
public
destroy(Uuid $id) : bool
Parameters
- $id : Uuid
-
The session ID being destroyed. The return value (usually TRUE on success, FALSE on failure).
Return values
boolexists()
Check if a session exists.
public
exists(Uuid $id) : bool
Parameters
- $id : Uuid
-
the session id
Return values
bool —true if the session exists, false otherwise
gc()
Cleanup old sessions Sessions that have not updated for the configured TTL will be removed.
public
gc() : array<string|int, Uuid>
Return values
array<string|int, Uuid>read()
Read session data.
public
read(Uuid $id) : string|false
Returns an encoded string of the read data. If nothing was read, it must return false.
Parameters
- $id : Uuid
-
the session id to read data for
Return values
string|falsewrite()
Write session data.
public
write(Uuid $id, string $data) : bool
Parameters
- $id : Uuid
-
the session id
- $data : string
-
the encoded session data
Return values
boolgetKey()
private
getKey(Uuid $id) : string
Parameters
- $id : Uuid