SessionManager
in package
Session management utility.
Handles session initialization, regeneration, flash messages, and secure session configuration.
Table of Contents
Properties
Methods
- __construct() : mixed
- destroy() : bool
- Destroy the session
- flash() : void
- Set a flash message (available for next request only)
- get() : mixed
- Get a session value
- getAllFlash() : array<string, mixed>
- Get all flash messages and clear them
- getFlash() : mixed
- Get a flash message
- getId() : string
- Get session ID
- has() : bool
- Check if session has a key
- hasFlash() : bool
- Check if flash message exists
- isStarted() : bool
- Check if session is started
- regenerate() : bool
- Regenerate session ID (prevent session fixation)
- remove() : void
- Remove a session value
- set() : void
- Set a session value
- start() : void
- Start the session with secure configuration
Properties
$_config
private
array<string, mixed>
$_config
= []
$_started
private
bool
$_started
= false
Methods
__construct()
public
__construct([array<string, mixed> $config = [] ]) : mixed
Parameters
- $config : array<string, mixed> = []
destroy()
Destroy the session
public
destroy() : bool
Return values
boolflash()
Set a flash message (available for next request only)
public
flash(string $key, mixed $value) : void
Parameters
- $key : string
- $value : mixed
get()
Get a session value
public
get(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
getAllFlash()
Get all flash messages and clear them
public
getAllFlash() : array<string, mixed>
Return values
array<string, mixed>getFlash()
Get a flash message
public
getFlash(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
getId()
Get session ID
public
getId() : string
Return values
stringhas()
Check if session has a key
public
has(string $key) : bool
Parameters
- $key : string
Return values
boolhasFlash()
Check if flash message exists
public
hasFlash(string $key) : bool
Parameters
- $key : string
Return values
boolisStarted()
Check if session is started
public
isStarted() : bool
Return values
boolregenerate()
Regenerate session ID (prevent session fixation)
public
regenerate([bool $deleteOldSession = true ]) : bool
Parameters
- $deleteOldSession : bool = true
Return values
boolremove()
Remove a session value
public
remove(string $key) : void
Parameters
- $key : string
set()
Set a session value
public
set(string $key, mixed $value) : void
Parameters
- $key : string
- $value : mixed
start()
Start the session with secure configuration
public
start() : void