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