I want to use session library in codeigniter 4,i read the codeigniter 4 documentation. I set the session library in constructor function, but i get error like this
I have set up session library like this :
class Login extends BaseController
{
protected $authModel;
protected $session;
public function __construct()
{
$this->session = \Config\Services::session();
$this->session->start();
$this->authModel = new AuthModel();
}
and I set the session value on my controler like this :
$userData = [
'username' => $result['result']['username'],
'role_id' => $result['result']['role_id'],
];
$this->session->set($userData); // setting session data
dd($this->session->get("username"));
But that's not working Please help me who knows the solution
CodePudding user response:
Edit your .env
file and set:
app.sessionSavePath = '/tmp/ci4_session'