Session
Sessions allow you to persist data across multiple requests for individual users. Common use cases include storing login status, user preferences, and temporary data.
Centum provides session classes that abstract session management, making it easy to interact with session data.
All session classes implement Centum\Interfaces\Http\SessionInterface
.
SessionInterface
defines the following public methods:
start(): bool
isActive(): bool
has(string $name): bool
get(string $name, mixed $defaultValue = null): mixed
set(string $name, mixed $value): void
remove(string $name): void
clear(): void
all(): array
Available Implementations
Centum provides different session implementations to suit various needs:
Centum\Http\Session\ArraySession
— Stores session data in memory (useful for testing).Centum\Http\Session\GlobalSession
— Uses PHP’s global$_SESSION
array.