SessionInterface
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
Starts the backing session before session state is accessed
Reports whether the backing session has already been initialized
Checks whether the session contains a value for the key
Returns the value for a key or the caller-provided fallback
Stores a value under the key for the current session
Removes the value stored under the key
Removes every value from the current session
Removes the active record, invalidates its identifier, and expires its browser cookie.
Replaces the current identifier and can invalidate its prior storage record
Details
start
void
start()
Starts the backing session before session state is accessed
started
bool
started()
Reports whether the backing session has already been initialized
has
bool
has(string $key)
Checks whether the session contains a value for the key
get
mixed
get(string $key, mixed $default = null)
Returns the value for a key or the caller-provided fallback
set
void
set(string $key, mixed $value)
Stores a value under the key for the current session
remove
void
remove(string $key)
Removes the value stored under the key
clear
void
clear()
Removes every value from the current session
destroy
void
destroy()
Removes the active record, invalidates its identifier, and expires its browser cookie.
A later access starts a new session identity.
regenerate
void
regenerate(bool $deleteOldSession = true)
Replaces the current identifier and can invalidate its prior storage record