MCP PHP SDK

Session implements SessionInterface

Tags
author

Kyrian Obikwelu koshnawaza@gmail.com

Table of Contents

Interfaces

SessionInterface

Properties

$data  : array<string, mixed>
Official keys are: - initialized: bool - client_info: array|null - client_capabilities: array|null - protocol_version: string|null - log_level: string|null
$id  : Uuid
$store  : SessionStoreInterface

Methods

__construct()  : mixed
all()  : array<string, mixed>
Get all attributes of the session.
clear()  : void
Remove all attributes from the session.
forget()  : void
Remove an attribute from the session.
get()  : mixed
Get a specific attribute from the session.
getId()  : Uuid
Get the session ID.
getStore()  : SessionStoreInterface
Get the session store instance.
has()  : bool
Check if an attribute exists in the session.
hydrate()  : void
Set all attributes of the session, typically for hydration.
jsonSerialize()  : array<string, mixed>
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.
readData()  : array<string, mixed>

Properties

$data

Official keys are: - initialized: bool - client_info: array|null - client_capabilities: array|null - protocol_version: string|null - log_level: string|null

private array<string, mixed> $data

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.

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>

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

save()

Save the session.

public save() : bool
Return values
bool

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

readData()

private readData() : array<string, mixed>
Return values
array<string, mixed>

        
On this page

Search results