How to use the session in CodeIgniter 4?

In CodeIgniter 4, we have no need to start and end session in each and every controller. We have need to change just few things, and then we can use session globally in any controller or page in our application. To do this, just follow the below few simple steps.
Step 1 Go to app->controller->BaseController.php
Step 2 Inside “class BaseController extends Controller” define $sessions as protected like below.
protected $session;
Step 3 Inside initController function there is line like below so just uncomment these line and save the file.
// $this->session = \Config\Services::session();


$this->session = \Config\Services::session();
Now session has been activated, you can use it now at any controller using $session.

How to set a session?

How to get session ?