Session
in package
Session manager with namespace support for multi-guard authentication.
Tags
Table of Contents
Methods
- delete() : void
- Delete a key from the session.
- destroy() : void
- Destroy the entire session.
- flash() : void
- Set a flash message (available for the next request only).
- get() : mixed
- Get a value from the session.
- getFlash() : mixed
- Get and remove a flash message.
- has() : bool
- Check if a key exists in the session.
- hasFlash() : bool
- Check if a flash message exists.
- regenerate() : void
- Regenerate the session ID (security measure after login).
- set() : void
- Set a value in the session.
- start() : void
- Start the session if not already started.
Methods
delete()
Delete a key from the session.
public
static delete(string $key) : void
Parameters
- $key : string
-
Session key (supports dot notation)
destroy()
Destroy the entire session.
public
static destroy() : void
flash()
Set a flash message (available for the next request only).
public
static flash(string $key, string $value) : void
Parameters
- $key : string
-
Flash key (e.g., "success", "error")
- $value : string
-
Flash message text
get()
Get a value from the session.
public
static get(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
-
Session key (supports dot notation for namespaces)
- $default : mixed = null
-
Default value if key not found
getFlash()
Get and remove a flash message.
public
static getFlash(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
-
Flash key
- $default : mixed = null
-
Default if not found
has()
Check if a key exists in the session.
public
static has(string $key) : bool
Parameters
- $key : string
-
Session key
Return values
boolhasFlash()
Check if a flash message exists.
public
static hasFlash(string $key) : bool
Parameters
- $key : string
-
Flash key
Return values
boolregenerate()
Regenerate the session ID (security measure after login).
public
static regenerate() : void
set()
Set a value in the session.
public
static set(string $key, mixed $value) : void
Parameters
- $key : string
-
Session key (supports dot notation)
- $value : mixed
-
Value to store
start()
Start the session if not already started.
public
static start() : void