MCP PHP SDK

SessionManager implements SessionManagerInterface

Default implementation of SessionManagerInterface.

Tags
author

Kyrian Obikwelu koshnawaza@gmail.com

Table of Contents

Interfaces

SessionManagerInterface
Factory interface for creating session instances.

Properties

$gcDivisor  : int
$gcProbability  : int
$logger  : LoggerInterface
$store  : SessionStoreInterface

Methods

__construct()  : mixed
create()  : SessionInterface
Creates a new session with an auto-generated UUID.
createWithId()  : SessionInterface
Creates a session with a specific UUID.
destroy()  : bool
Destroys the session with the given UUID.
exists()  : bool
Checks if a session with the given UUID exists.
gc()  : void
Run garbage collection on expired sessions.

Properties

$logger read-only

private LoggerInterface $logger = new NullLogger()

Methods

__construct()

public __construct(SessionStoreInterface $store[, LoggerInterface $logger = new NullLogger() ][, int $gcProbability = 1 ][, int $gcDivisor = 100 ]) : mixed
Parameters
$store : SessionStoreInterface
$logger : LoggerInterface = new NullLogger()
$gcProbability : int = 1

The probability (numerator) that GC will run on any given request. Combined with $gcDivisor to calculate the actual probability. Set to 0 to disable GC. Similar to PHP's session.gc_probability.

$gcDivisor : int = 100

The divisor used with $gcProbability to calculate GC probability. The probability is gcProbability/gcDivisor (e.g. 1/100 = 1%). Similar to PHP's session.gc_divisor.

destroy()

Destroys the session with the given UUID.

public destroy(Uuid $id) : bool
Parameters
$id : Uuid
Return values
bool

exists()

Checks if a session with the given UUID exists.

public exists(Uuid $id) : bool
Parameters
$id : Uuid
Return values
bool

gc()

Run garbage collection on expired sessions.

public gc() : void

Uses the session store's internal TTL configuration.

On this page

Search results