The Session class within the Boostack\Models\Session namespace handles user session operations in a web application.
The Session class is designed to manage user sessions, providing methods to initialize a session, retrieve and set session values, handle user login and logout, check login status, and manage CSRF protection.
To enable session management, you need to set $config['session_on']
to TRUE in the config/env.php configuration file.
Session management is done using the database and therefore requires that $config['database_on']
is set to TRUE.
use Boostack\Models\Session\Session; if (empty(Session::get("current_year"))) { Session::set("current_year", date("Y")); // store session variable in database }
The methods of the Session class that handle the login and logout of the current user are wrapped within specific methods of the Auth class. It is recommended to use the Auth class to manage these scenarios.
Session::get($key)
Session::set($key, $value)
Session::getUserObject()
Session::getUserID()
Session::loginUser($userID)
Session::logoutUser()
Session::isLoggedIn()
Session::CSRFCheckValidity($postArray, $throwException)
Session::CSRFRenderHiddenField()