Skip to the content.

Session

A sessions provide way to store information about the user across multiple requests.

Use session middleware to use session:

$app->use($app->session());

Set session data:

// Set new session data
$req->session->set('email', 'example@gmail.com');

Get the session data:

// Get session data
$req->session->get('email');

Check session data exists or not:

// Get session exists or not
if($req->session->has('email')) {
    // Session data exists
} else {
    // Session data not exists
}

Delete the session data:

// Delete a session data
$req->session->delete('email');

It will delete only session variable data.

Delete the all session data:

// Delete all session
$req->session->destroy();

It will delete all session data.