Change cookie cookie expiration and session timeout for CakePHP session

I try my best to do the following: Change the expiration date of the user's session cookie depending on the type of user.

I have a CakePHP web application in which I created my authentication component (instead of CakePHP Auth) using CakePHP sessions. I configured CakePHP to handle sessions using the database.

Here are the configuration settings that I have in the config.php file:

Configure::write('Session.save', 'database'); Configure::write('Session.timeout', '36'); Configure::write('Security.level', 'medium'); 

How to extend the session cookie expiration date AND update the value in the column "expires" in the table " ?

+6
source share
2 answers

Go to app / config / core.php

In this file, find

 Configure::write('Session.timeout', '120'); 

Session timeout (in seconds), the default is 120 seconds. You can edit it here as needed. Now the actual timeout duration depends on

 Configure::write('Security.level', 'medium'); if 'high' then Session timeout in 'Session.timeout' x 10, if 'medium' then Session timeout in 'Session.timeout' x 100, if 'low' Session timeout in 'Session.timeout' x 300 

Thus, by combining Session.timeout and Security.level you can get the desired session timeout

+6
source

Find this: app/config/core.php

Change this line to the desired value in minutes:
Configure::write('Session.timeout', '120');

(Since CakePHP 2.3.0 Security.level no longer used.
Changelog: http://cakephp.org/changelogs/2.3.0 )

+4
source

Source: https://habr.com/ru/post/908506/


All Articles