MCP PHP SDK

EphemeralSession extends Session implements EphemeralSessionInterface

FinalYes

The session of one request on a server built without {@see \Mcp\Server\Builder::setSession()}.

It lives as long as its request and is never stored, so it cannot be saved.

Tags
author

Ruud Kamphuis ruudk@users.noreply.github.com

Table of Contents

Interfaces

EphemeralSessionInterface
A session that lives as long as its request and is never stored.

Methods

__construct()  : mixed
all()  : array<string, mixed>
Get all attributes of the session.
clear()  : void
Remove all attributes from the session, including who opened it: once saved, the session serves no one.
forget()  : void
Remove an attribute from the session.
get()  : mixed
Get a specific attribute from the session.
getId()  : Uuid
Get the session ID.
has()  : bool
Check if an attribute exists in the session.
hydrate()  : void
Set all attributes of the session, typically for hydration.
isUnreadable()  : bool
Whether the store holds this session but failed to return it, unlike a session without attributes.
jsonSerialize()  : array<string, mixed>
pull()  : mixed
Get an attribute's value and then remove it from the session.
save()  : never
Save the session.
set()  : void
Set a specific attribute in the session.

Methods

all()

Get all attributes of the session.

public all() : array<string, mixed>
Return values
array<string, mixed>

clear()

Remove all attributes from the session, including who opened it: once saved, the session serves no one.

public clear() : void

forget()

Remove an attribute from the session.

public forget(string $key) : void

Supports dot notation for nested access.

Parameters
$key : string

get()

Get a specific attribute from the session.

public get(string $key[, mixed $default = null ]) : mixed

Supports dot notation for nested access.

Parameters
$key : string
$default : mixed = null

getId()

Get the session ID.

public getId() : Uuid
Return values
Uuid

has()

Check if an attribute exists in the session.

public has(string $key) : bool

Supports dot notation for nested access.

Parameters
$key : string
Return values
bool

hydrate()

Set all attributes of the session, typically for hydration.

public hydrate(array<string|int, mixed> $attributes) : void

This will overwrite existing attributes.

Parameters
$attributes : array<string|int, mixed>

isUnreadable()

Whether the store holds this session but failed to return it, unlike a session without attributes.

public isUnreadable() : bool
Return values
bool

jsonSerialize()

public jsonSerialize() : array<string, mixed>
Return values
array<string, mixed>

pull()

Get an attribute's value and then remove it from the session.

public pull(string $key[, mixed $default = null ]) : mixed

Supports dot notation for nested access.

Parameters
$key : string
$default : mixed = null

set()

Set a specific attribute in the session.

public set(string $key, mixed $value[, bool $overwrite = true ]) : void

Supports dot notation for nested access.

Parameters
$key : string
$value : mixed
$overwrite : bool = true
On this page

Search results