Neuron-PHP

ISession

Interface for session management abstraction.

Provides a testable abstraction over PHP session operations. Implementations can be real sessions for production or in-memory sessions for testing.

Table of Contents

Methods

all()  : array<string|int, mixed>
Get all session data
clear()  : void
Clear all session data
destroy()  : bool
Destroy the session completely
flash()  : void
Set flash message (available only on next request)
get()  : mixed
Get value from session
getFlash()  : mixed
Get flash message (automatically removed after retrieval)
getId()  : string
Get session ID
has()  : bool
Check if a key exists in session
isStarted()  : bool
Check if session is started
regenerate()  : bool
Regenerate session ID (prevents session fixation attacks)
remove()  : void
Remove key from session
set()  : void
Set value in session
start()  : void
Start the session

Methods

all()

Get all session data

public all() : array<string|int, mixed>
Return values
array<string|int, mixed>

All session data

clear()

Clear all session data

public clear() : void

destroy()

Destroy the session completely

public destroy() : bool
Return values
bool

Success status

flash()

Set flash message (available only on next request)

public flash(string $key, mixed $value) : void
Parameters
$key : string

Flash key

$value : mixed

Flash value

get()

Get value from session

public get(string $key[, mixed $default = null ]) : mixed
Parameters
$key : string

Session key

$default : mixed = null

Default value if key doesn't exist

Return values
mixed

Session value or default

getFlash()

Get flash message (automatically removed after retrieval)

public getFlash(string $key[, mixed $default = null ]) : mixed
Parameters
$key : string

Flash key

$default : mixed = null

Default value if flash doesn't exist

Return values
mixed

Flash value or default

getId()

Get session ID

public getId() : string
Return values
string

Session ID

has()

Check if a key exists in session

public has(string $key) : bool
Parameters
$key : string

Session key

Return values
bool

True if key exists

isStarted()

Check if session is started

public isStarted() : bool
Return values
bool

True if session is active

regenerate()

Regenerate session ID (prevents session fixation attacks)

public regenerate([bool $deleteOld = true ]) : bool
Parameters
$deleteOld : bool = true

Whether to delete old session file

Return values
bool

Success status

remove()

Remove key from session

public remove(string $key) : void
Parameters
$key : string

Session key

set()

Set value in session

public set(string $key, mixed $value) : void
Parameters
$key : string

Session key

$value : mixed

Value to store

start()

Start the session

public start() : void

        
On this page

Search results