interface SessionInterface (View source)

Provides request-scoped access to keyed session state.

Portable values are null, scalars, and arrays composed of portable values. Object restoration is deliberately not part of the storage-neutral contract.

Methods

void
start()

Starts the backing session before session state is accessed

void
bool

Reports whether the backing session has already been initialized

bool
bool
has(string $key)

Checks whether the session contains a value for the key

bool
mixed
get(string $key, mixed $default = null)

Returns the value for a key or the caller-provided fallback

mixed
void
set(string $key, mixed $value)

Stores a value under the key for the current session

void
void
remove(string $key)

Removes the value stored under the key

void
void
clear()

Removes every value from the current session

void
void

Removes the active record, invalidates its identifier, and expires its browser cookie.

void
void
regenerate(bool $deleteOldSession = true)

Replaces the current identifier and can invalidate its prior storage record

void

Details

start

void start()

Starts the backing session before session state is accessed

Return Value

void

started

bool started()

Reports whether the backing session has already been initialized

Return Value

bool

has

bool has(string $key)

Checks whether the session contains a value for the key

Parameters

string $key

Return Value

bool

get

mixed get(string $key, mixed $default = null)

Returns the value for a key or the caller-provided fallback

Parameters

string $key
mixed $default

Return Value

mixed

set

void set(string $key, mixed $value)

Stores a value under the key for the current session

Parameters

string $key
mixed $value

Return Value

void

remove

void remove(string $key)

Removes the value stored under the key

Parameters

string $key

Return Value

void

clear

void clear()

Removes every value from the current session

Return Value

void

destroy

void destroy()

Removes the active record, invalidates its identifier, and expires its browser cookie.

A later access starts a new session identity.

Return Value

void

regenerate

void regenerate(bool $deleteOldSession = true)

Replaces the current identifier and can invalidate its prior storage record

Parameters

bool $deleteOldSession

Return Value

void