Session
Reference for the Session module: read and write typed values in the PHP session by name. The session is started lazily on first use, integers and strings are read back through the type conversion helpers, and the current session id is available.
This page is a pure reference. For how the framework fits together, see the Guide.
Session- static functions to read and write typed values in the PHP session.
Session
Static functions for the PHP session, listed alphabetically. Each call starts the session on first use if it is not already started. Values are stored by name; integers and strings are read back through the type conversion helpers.
AddInteger
Session::AddInteger(string $name, int $value): int
Store an integer in the session under a name.
| Name | Type | Description |
|---|---|---|
$name | string | The name to store the value under. |
$value | int | The integer to store. |
Returns int The value that was stored.
AddString
Session::AddString(string $name, string $value): string
Store a string in the session under a name.
| Name | Type | Description |
|---|---|---|
$name | string | The name to store the value under. |
$value | string | The string to store. |
Returns string The value that was stored.
GetInteger
Session::GetInteger(string $name, int|null $default = null): int|null
Read an integer from the session, or the default when the name is not set.
| Name | Type | Description |
|---|---|---|
$name | string | The name to read. |
$default | int|null | The value to return when the name is not set. |
Returns int|null The stored integer, or the default.
GetSessionId
Session::GetSessionId(): string
The current session id, starting the session first if needed.
Returns string The session id.
GetString
Session::GetString(string $name, string|null $default = null): string|null
Read a string from the session, or the default when the name is not set.
| Name | Type | Description |
|---|---|---|
$name | string | The name to read. |
$default | string|null | The value to return when the name is not set. |
Returns string|null The stored string, or the default.
RemoveEntry
Session::RemoveEntry(string $name): void
Remove a value from the session by name, if it is set.
| Name | Type | Description |
|---|---|---|
$name | string | The name to remove. |
Returns void