class Session

Class Session.

Tools for managing sessions, including session segments and read-once messages

Traits

Trait Singleton, This class ensures that all class that use this have only one instance of itself if called as: Class::getInstance()

Properties

static protected bool $singletonArray Set to true if you want use more that one singleton using and index param in getInstance from Singleton
static protected string $basePath The base path where config files are placed. from Singleton
static private string $className Name of the class from Singleton
static private array $instances Hold the classes on instance. from Singleton
protected bool $separateConfigFile Set to true if you want to save configuration in a separate file from Singleton
protected Session $session Session info from cookie.
protected string $segmentName Segment name.

Methods

static Session
getInstance()

Return this instance.

static string
getClassName()

Returns the class name.

from Singleton
bool
setConfig(array $params, bool $merge = true, string $index = 'main')

Save config to file.

from Singleton
array
getYamlContent()

Returns the content of the Yaml file.

from Singleton
string
getFilePath()

Return the full file config path.

from Singleton
string
getFileName()

Return the file name.

from Singleton
static string
yamlName()

Return the classname for yaml file.

from Singleton
bool
fileExists(string $filename)

Returns if file exists.

from Singleton
array
getConfig(string $index = 'main')

Returns the yaml config params.

from Singleton
static array
getDefaultValues()

Return default values

string
getBasePath()

Return the base path.

from Singleton
initSingleton()

Initialization, equivalent to __construct and must be called from main class.

from Singleton
__construct()

Session constructor.

string
getCsrfToken()

Gets the value of the outgoing CSRF token.

bool
isValid(string $csrfToken)

Checks whether an incoming CSRF token value is valid.

Session
getSession()

Return this session.

setSegment(string $segmentName)

Sets segment name.

mixed
get(string $key)

Get data from segment.

Segment
getSegment()

Return segment session.

$this
set(string $key, mixed $value)

Set data key.

$this
setFlash(string $key, mixed $value)

Sets flash next data by key.

$this
setFlashNext(string $key, mixed $value)

Sets flash next data by key.

mixed
getFlash(string $key)

Get flash now data by key.

mixed
getFlashNow(string $key)

Get flash now data by key.

$this
setFlashNow(string $key, mixed $value)

Sets flash now data by key.

mixed
getFlashNext(string $key)

Get flash next data by key.

Details

at line 65
static Session getInstance()

Return this instance.

Return Value

Session

in Singleton at line 88
static private string getClassName()

Returns the class name.

Return Value

string

in Singleton at line 103
bool setConfig(array $params, bool $merge = true, string $index = 'main')

Save config to file.

Parameters

array $params
bool $merge
string $index

Return Value

bool

in Singleton at line 130
private array getYamlContent()

Returns the content of the Yaml file.

Return Value

array

in Singleton at line 152
string getFilePath()

Return the full file config path.

Return Value

string

in Singleton at line 162
string getFileName()

Return the file name.

Return Value

string

in Singleton at line 172
static string yamlName()

Return the classname for yaml file.

Return Value

string

in Singleton at line 184
protected bool fileExists(string $filename)

Returns if file exists.

Parameters

string $filename

Return Value

bool

in Singleton at line 196
array getConfig(string $index = 'main')

Returns the yaml config params.

Parameters

string $index

Return Value

array

at line 75
static array getDefaultValues()

Return default values

Return Value

array

in Singleton at line 215
string getBasePath()

Return the base path.

Return Value

string

in Singleton at line 223
protected initSingleton()

Initialization, equivalent to __construct and must be called from main class.

at line 43
__construct()

Session constructor.

at line 86
string getCsrfToken()

Gets the value of the outgoing CSRF token.

Return Value

string

at line 98
bool isValid(string $csrfToken)

Checks whether an incoming CSRF token value is valid.

Parameters

string $csrfToken

Return Value

bool

at line 108
Session getSession()

Return this session.

Return Value

Session

at line 120
Session setSegment(string $segmentName)

Sets segment name.

Parameters

string $segmentName

Return Value

Session

at line 133
mixed get(string $key)

Get data from segment.

Parameters

string $key

Return Value

mixed

at line 143
Segment getSegment()

Return segment session.

Return Value

Segment

at line 156
$this set(string $key, mixed $value)

Set data key.

Parameters

string $key
mixed $value

Return Value

$this

at line 170
$this setFlash(string $key, mixed $value)

Sets flash next data by key.

Parameters

string $key
mixed $value

Return Value

$this

at line 184
$this setFlashNext(string $key, mixed $value)

Sets flash next data by key.

Parameters

string $key
mixed $value

Return Value

$this

at line 197
mixed getFlash(string $key)

Get flash now data by key.

Parameters

string $key

Return Value

mixed

at line 209
mixed getFlashNow(string $key)

Get flash now data by key.

Parameters

string $key

Return Value

mixed

at line 222
$this setFlashNow(string $key, mixed $value)

Sets flash now data by key.

Parameters

string $key
mixed $value

Return Value

$this

at line 235
mixed getFlashNext(string $key)

Get flash next data by key.

Parameters

string $key

Return Value

mixed