1

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.

  • Have you tried to change session.timeout in core.php – Akshay Sharma Jun 17 '16 at 09:14
  • Well, I haven't tried anything yet. I have been reading too much things about how to set a specific time, but I don't want it, I don't want to set 12312312312231 minutes for example, I just want to block the expiring of user session –  Jun 17 '16 at 09:18

2 Answers2

1

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.

Akshay Sharma
  • 1,042
  • 1
  • 8
  • 21
  • Well, I have found a way where you do not have to call an ajax request. If you set the timeout like this: `Configure::write('Session', array( 'defaults' => 'php', 'Session.timeout' => 0 ));` It makes the session "infinite" –  Jun 17 '16 at 18:04
-1
$this->Session->destroy();

The destroy method will delete the session, cookie and all session data stored in temporary file system.

User to remove, use better delete.

$this->Session->delete('User');
A J
  • 3,970
  • 14
  • 38
  • 53