MCP PHP SDK

FileSessionStore implements SessionStoreInterface

File-based session store.

Stores each session as a file named by the RFC4122 UUID, with the payload.

Table of Contents

Interfaces

SessionStoreInterface

Properties

$clock  : ClockInterface
$directory  : string
$ttl  : int

Methods

__construct()  : mixed
destroy()  : bool
Destroy a session.
exists()  : bool
Check if a session exists.
gc()  : array<string|int, Uuid>
Remove sessions older than the configured TTL.
read()  : string|false
Read session data.
write()  : bool
Write session data.
pathFor()  : string

Properties

Methods

__construct()

public __construct(string $directory[, int $ttl = 3600 ][, ClockInterface $clock = new NativeClock() ]) : mixed
Parameters
$directory : string
$ttl : int = 3600
$clock : ClockInterface = new NativeClock()

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
bool

exists()

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()

Remove sessions older than the configured TTL.

public gc() : array<string|int, Uuid>

Returns an array of deleted session IDs (UUID instances).

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|false

write()

Write session data.

public write(Uuid $id, string $data) : bool
Parameters
$id : Uuid

the session id

$data : string

the encoded session data

Return values
bool

pathFor()

private pathFor(Uuid $id) : string
Parameters
$id : Uuid
Return values
string

        
On this page

Search results