Ses
Low-level PHP session handling.
Lifecycle 9
- start Reads the session if this request hasn't yet. $options are session_start()'s, e.g. ['gc_maxlifetime' => 3600].
- isStarted Whether this request has read the session - it may hold a flash message or the visitor's own state.
- reads How many times session data was read or written so far.
- isActive Whether the session is open for writing at this moment, holding its lock.
- hasCookie Whether the request carries a session cookie, checkable without starting a session.
- close Writes and closes the session if it is open, and forgets it was read, so the next start() reads it again.
- id The session id.
- regenerate Gives the session a new id, keeping its values.
- destroy Ends the session and clears its values.
Flash 3
- setFlash Stores a value for the next request only.
- getFlash A flashed value, or null.
- deleteFlash Removes a flashed value.
Lifecycle
Ses::start(array $options = []): void
Reads the session if this request hasn't yet. $options are session_start()'s, e.g. ['gc_maxlifetime' => 3600].
Parameters (1)
| $options | array = [] |
phlat/src/Toolkit/Ses.php:27
Ses::isStarted(): bool
Whether this request has read the session - it may hold a flash message or the visitor's own state.
Returns bool
phlat/src/Toolkit/Ses.php:39
Ses::reads(): int
How many times session data was read or written so far.
Returns int
phlat/src/Toolkit/Ses.php:49
Ses::isActive(): bool
Whether the session is open for writing at this moment, holding its lock.
Returns bool
phlat/src/Toolkit/Ses.php:55
Ses::hasCookie(): bool
Whether the request carries a session cookie, checkable without starting a session.
Returns bool
phlat/src/Toolkit/Ses.php:61
Ses::close(): void
Writes and closes the session if it is open, and forgets it was read, so the next start() reads it again.
phlat/src/Toolkit/Ses.php:67
Ses::regenerate(): bool
Gives the session a new id, keeping its values.
Returns bool
phlat/src/Toolkit/Ses.php:81
Data
Ses::get(string $key): mixed
The value under $key, or null.
Parameters (1)
| $key | string |
Returns mixed
phlat/src/Toolkit/Ses.php:113
Ses::set(string $key, mixed $value): void
Stores a value under $key.
Parameters (2)
| $key | string | |
| $value | mixed |
phlat/src/Toolkit/Ses.php:120
Ses::ensure(string $key, mixed $value): mixed
The value under $key, storing $value first when there is none.
Parameters (2)
| $key | string | |
| $value | mixed |
Returns mixed
phlat/src/Toolkit/Ses.php:128
Ses::has(string $key): bool
Whether a value is stored under $key.
Parameters (1)
| $key | string |
Returns bool
phlat/src/Toolkit/Ses.php:137
Ses::delete(string $key): void
Removes the value under $key.
Parameters (1)
| $key | string |
phlat/src/Toolkit/Ses.php:144
Flash
Ses::setFlash(string $key, mixed $value): void
Stores a value for the next request only.
Parameters (2)
| $key | string | |
| $value | mixed |
phlat/src/Toolkit/Ses.php:163
Ses::getFlash(string $key): mixed
A flashed value, or null.
Parameters (1)
| $key | string |
Returns mixed
phlat/src/Toolkit/Ses.php:171
Ses::deleteFlash(string $key): void
Removes a flashed value.
Parameters (1)
| $key | string |
phlat/src/Toolkit/Ses.php:178