codeigniter 4 sessions confuse user

Viewed 17

I am using codeigniter 4, I am having problems with sessions.

The session is initialized and set.

But if another user logs in, it happens that the first user is thrown out.

Or it happens that the session lasts two or three minutes and the user is thrown out at login (as if the session had expired).

How can I tell codeigniter to initialize the session for each user uniquely ??

this is the session configuration app/Config/App.php:

        //Database
        $this->sessionDriver = 'CodeIgniter\Session\Handlers\DatabaseHandler';        
        $this->sessionCookieName = 'ci_sessions';
        $this->sessionRegenerateDestroy = false;
        $this->sessionTimeToUpdate = 1800;
        $this->sessionMatchIP = true;
        $this->sessionSavePath = 'ci_sessions';
        $this->sessionExpiration = 0;
        $this->cookieDomain = '.mydamain.com';

in class BaseController extends Controller{: // class BaseController

        $this->session = \Config\Services::session();

set session in Model : class MO_Login extends BaseModel{

        $expire=1800;
        $this->session->setTempdata('id_user',value,$expire);
        $this->session->setTempdata('username',value1,$expire);

in other controller:

        public function index(){
           if($this->session->getTempdata("username")){
              $this->Main();
           }else{
              return redirect()->to(base_url('/CO_Login'));
           }
        } 

can you give me an indication where I am wrong thanks.

0 Answers
Related