Sessions


Description


The session class replaces PHPs standard session storage functions and lets you use PHPs own sessions functions and variables. The supported storage types are:

  • Database
  • Native *
  • Redis
* uses the defaul PHP storage functions.

Methods


start([string $name = null])


Starting a session is done using the start method. You use it instead of PHPs own session_start function.


Session::start('redis'); // Start a session using the redis configuration

// You can now use the $_SESSION variable and PHP session functions like you would after calling "session_start()"

$_SESSION['foo'] = 'bar';

flash([mixed $data = null])


The flash method allows you to set and get flash data. Flash data will be deleted from the session as soon as it has been read.

Calling the flash method will automatically start the session if it hasn't already been started.


// Store a flash message for later use

Session::flash('Your password has been updated');

// Print flash message and delete it from the session

echo Session::flash();