Responsibility - session data management - starting, writing and expirations.
- Safe start (only once) - By \MvcCore\Session::Start()
- Called by \MvcCore\Application::GetInstance()->SessionStart();
- Called by \MvcCore\Controller::Init();
.
- Session writing and closing at request end: - In \MvcCore\Session::Close()
- Called over register_shutdown_function()
from \MvcCore::Terminate();
- Session namespaces management: - Variables expiration by seconds. - Variables expiration by request hoops.
Methods summary
public static
|
#
Start( )
Session safe start only once.
- called by \MvcCore\Application::GetInstance()->SessionStart();
- called by \MvcCore\Controller::Init();
It's free to call this function anywhere sooner for custom purposes,
for example in Bootstrap.php by: \MvcCore\Application::GetInstance()->SessionStart();
Session safe start only once.
- called by \MvcCore\Application::GetInstance()->SessionStart(); - called by \MvcCore\Controller::Init();
It's free to call this function anywhere sooner for custom purposes,
for example in Bootstrap.php by: \MvcCore\Application::GetInstance()->SessionStart();
|
public static
integer
|
#
GetSessionStartTime( )
Get Unix epoch for current request session start moment.
Get Unix epoch for current request session start moment.
Returns
integer
|
public static
boolean
|
#
GetStarted( )
Get static boolean about if session has been already started or not.
Get static boolean about if session has been already started or not.
Returns
boolean
|
public static
stdClass
|
#
GetSessionMetadata( )
Get session metadata about session namespaces.
This method is used for debugging purposes.
Get session metadata about session namespaces.
This method is used for debugging purposes.
Returns
stdClass
|
public static
|
#
Close( )
Write and close session in \MvcCore::Terminate(); .
Serialize all metadata and call php function to write session into php session storage.
(HDD, Redis, database, etc., depends on php configuration).
Write and close session in \MvcCore::Terminate(); .
Serialize all metadata and call php function to write session into php session storage.
(HDD, Redis, database, etc., depends on php configuration).
|
public static
MvcCore\Session
|
#
GetNamespace( string $name = \MvcCore\ISession::DEFAULT_NAMESPACE_NAME )
Get new or existing MvcCore session namespace instance.
If session is not started, start session.
Get new or existing MvcCore session namespace instance.
If session is not started, start session.
Parameters
- $name
- Session namespace unique name.
Returns
|
public
MvcCore\Session
|
#
SetExpirationHoops( integer $hoops )
Set MvcCore session namespace expiration by page request(s) count.
Set MvcCore session namespace expiration by page request(s) count.
Parameters
Returns
|
public
MvcCore\Session
|
#
SetExpirationSeconds( integer $seconds )
Set MvcCore session namespace expiration by expiration seconds.
Zero (0 ) means "until the browser is closed" if there is no more
higher namespace expirations in whole session.
Set MvcCore session namespace expiration by expiration seconds.
Zero (0 ) means "until the browser is closed" if there is no more
higher namespace expirations in whole session.
Parameters
Returns
|
public static
|
#
SendCookie( )
Send PHPSESSID http cookie with session id hash before response body is sent.
This function is always called by \MvcCore\Application::Terminate(); at the request end.
Send PHPSESSID http cookie with session id hash before response body is sent.
This function is always called by \MvcCore\Application::Terminate(); at the request end.
|
public static
integer
|
#
GetSessionMaxTime( )
Get the highest expiration in seconds for namespace with
the highest expiration to set expiration for PHPSESSID cookie.
Get the highest expiration in seconds for namespace with
the highest expiration to set expiration for PHPSESSID cookie.
Returns
integer
|
public
|
#
Destroy( )
Destroy whole session namespace in $_SESSION storage
and internal static storages.
Destroy whole session namespace in $_SESSION storage
and internal static storages.
|
public static
|
#
DestroyAll( )
Destroy all existing session namespaces in $_SESSION storage
and internal static storages, destroy whole PHP session.
Destroy all existing session namespaces in $_SESSION storage
and internal static storages, destroy whole PHP session.
|
public
mixed
|
#
__get( string $key )
Magic function triggered by: $value = \MvcCore\Session->key; .
Magic function triggered by: $value = \MvcCore\Session->key; .
Parameters
Returns
mixed
|
public
|
#
__set( string $key, mixed $value )
Magic function triggered by: \MvcCore\Session->key = "value"; .
Magic function triggered by: \MvcCore\Session->key = "value"; .
Parameters
|
public
boolean
|
#
__isset( string $key )
Magic function triggered by: isset(\MvcCore\Session->key); .
Magic function triggered by: isset(\MvcCore\Session->key); .
Parameters
Returns
boolean
|
public
|
#
__unset( string $key )
Magic function triggered by: unset(\MvcCore\Session->key); .
Magic function triggered by: unset(\MvcCore\Session->key); .
Parameters
|