MCP PHP SDK

EphemeralSessionInterface extends SessionInterface

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

The server refuses what would have to outlast the request on it, like requests to the client and resource subscriptions.

Tags
author

Ruud Kamphuis ruudk@users.noreply.github.com

Table of Contents

Methods

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.
pull()  : mixed
Get an attribute's value and then remove it from the session.
save()  : bool
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

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, mixed> $attributes) : void

This will overwrite existing attributes.

Parameters
$attributes : array<string, mixed>

isUnreadable()

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

public isUnreadable() : bool
Tags
throws
SessionStoreException

if the store cannot be reached

Return values
bool

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