Sessions
Session support is implemented via the standard PHP session using the Session class, which stores the user's session data in a separate container. The session starts automatically upon the creation of the MV object.
To activate the session, you need to set the configuration in the config/setup.php file.
'SessionSupport' => trueThe main methods for working with session data are listed below. They are all static and can be called from anywhere in the application.
Основные методы для работы с данными сессии перечислены ниже. Все они являются статическими и могут быть вызваны из любого места приложения.
//Set a value
Session::set('key_name', 'value');
//Get a value, the second argument is an optional default value
//if the 'key_name' key is missing
$value = Session::get('key_name');
$value = Session::get('key_name', '');
//Check for the existence of all listed keys in the session
if(Session::has('key_1', 'key_2', 'key_3'))
{
...
}
//Get all keys and values from the session as an array
$data = Session::all();
//Remove a key and its value from the session
Session::remove('key_name');
//Delete all session data
Session::clear();
//Get the session parameters set when it was started
$value = Session::getParameter('ip_hash');
$value = Session::getParameter('browser_hash');
$value = Session::getParameter('start_time');
Previous section
AJAX