Neuron-PHP

RealSession
in package
implements ISession

Real session implementation using PHP native session functions.

This is the production implementation that uses actual PHP sessions.

Table of Contents

Interfaces

ISession
Interface for session management abstraction.

Constants

FLASH_KEY  = '_flash'
FLASH_NEW_KEY  = '_flash_new'

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
ageFlashData()  : void
Age flash data - move new flash to old, remove old flash

Constants

FLASH_NEW_KEY

private mixed FLASH_NEW_KEY = '_flash_new'

Methods

all()

Get all session data

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

All session data

clear()

Clear all session data

public clear() : void
Tags
inheritDoc

destroy()

Destroy the session completely

public destroy() : bool
Tags
inheritDoc
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

Tags
inheritDoc

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

Tags
inheritDoc
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

Tags
inheritDoc
Return values
mixed

Flash value or default

getId()

Get session ID

public getId() : string
Tags
inheritDoc
Return values
string

Session ID

has()

Check if a key exists in session

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

Session key

Tags
inheritDoc
Return values
bool

True if key exists

isStarted()

Check if session is started

public isStarted() : bool
Tags
inheritDoc
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

Tags
inheritDoc
Return values
bool

Success status

remove()

Remove key from session

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

Session key

Tags
inheritDoc

set()

Set value in session

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

Session key

$value : mixed

Value to store

Tags
inheritDoc

start()

Start the session

public start() : void
Tags
inheritDoc

ageFlashData()

Age flash data - move new flash to old, remove old flash

private ageFlashData() : void

        
On this page

Search results