Instead of managing the $_SESSION
variable directly, you can use the Wolff Session class.
All the session methods work with the time expressed in minutes (unless it’s specified here).
Just remember to use Core\Session
.
Start the session:
Session::start();
Count the session variables:
Session::count();
Set the session global time:
Session::setTime(10);
Get the session time (in seconds):
Session::getStartTime();
Get session time with format (Hours, minutes and seconds):
Session::getStartTime(true);
Get session remaining time (in seconds):
Session::getRemainingTime();
Get session remaining time with format (Hours, minutes and seconds):
Session::getRemainingTime(true);
Unset session:
Session::empty();
Destroy session:
Session::kill();
Declare a session variable:
Session::set('name', $value);
Getting a session variable:
Session::get('name');
Check if a session variable exists:
Session::has('name');
Unset a session variable:
Session::unset('name');
Getting variable time (in seconds):
Session::getVarTime('name');
Getting variable time with format (Hours, minutes and seconds):
Session::getVarTime('name', true);
Set the variable live time:
Session::setVarTime('name', 10);
Adding time to a variable:
Session::addVarTime('name', 10);