For simple session management the framework offers class waStorage
. An instance of waStorage
is accessible within the PHP code
of controllers and actions using the following syntax:
$session = $this->getStorage();
Example of the session variables management:
// Reading the value of a session variable $session_var = $this->getStorage()->read('session_var'); // Reading the value of a session variable and deleting it right away $session_var = $this->getStorage()->getOnce('session_var'); // Reading all session variables $session_vars = $this->getStorage()->getAll(); // Assigning a value to a session variable $this->getStorage()->write('session_var', $value); // Deleting a session variable $this->getStorage()->remove('session_var'); //Closing a session $this->getStorage()->close();
Authorized user
An authorized user is represented by an instance of class waContact
in the system. You can obtain the user object in controllers and actions using
the following syntax:
$user = $this->getUser(); // returns a waContact object
An example of obtaining an instance of class waContact
in other parts of the source code (e.g., in the model):
$user = wa()->getUser();
Examples of retrieving user data:
$user->getId(); $user->getName(); $user->getLocale(); $user->getTimezone();