I have this function in my codeigniter 4 controller
private function setUserSession($user) { $data = [ \'id\' => $user[\'id\'], \'username\