phpsessioncakephpusersession

How not to expire user session cakephp


I'm developing an application in CakePHP for monitoring and I do not want my user session to expire because user needs to needs to see the control panel frequently even if he is not using the application.

I have found many ways but I do not know which is the best one...

What do you recommend?

Thanks a lot in advance. Best regards.


Solution

  • Go to config/core.php file , set session settings like this

    Configure::write('Session', array(
            'defaults' => 'php',
            'Session.timeout' => '12312312312231'
        ));
    

    Now you can change session timeout as you like.
    If you not set session timeout time then you need to access your after login function through ajax request in a time period.You need to run a ajax request in 1 minute interval to your after login any controller function. like this
    create a function ajax_request() in your after login controller. Now

    setInterval(function(){
    //Your ajax code
    },1000);
    

    When ajax request goes to your controller function then auth component always extends expiry time.