cakephp session timeout not working

could not start the session cakephp 3
method session does not exist cakephp
cakephp 4 session

I have cakephp site, I was having problem that was after being idle for about >= 1 hour it gets log-out automatically so I googled to extend timeout for that I wrote the following in core.php

    Configure::write('Session', array(
        'defaults' => 'php',
        'timeout'  => 28800,  // 8 hours.

I want to keep a logged in user logged-in even after being idle for less than 8hours but this is not working how can I sort out this?

According to CakePHP manual, the unit of Session.timeout option is "minute", so 8 hours should be 60*8=480

Regarding the setting not work, I think maybe you could try to clean the cakePHP cache files / restart web server or change the debug level to 2 for troubleshooting?

CakePHP 2.0 manual sessions

3.0, Hi guys. I'm pretty sure this worked at some point, but setting the timeout in Session config has no (or seems to not have any) effect right now. If the docs are right - then setting Session.timeout doesn't affect Session.cookieTimeout, and neither of those things affects the actual expiration of the session cookie.

May be you are using CakePHP 3, that is why you are facing this issue. Session timeout does not work in CakePHP 3, You might use cookie_lifetime, please check

Sessions - 3.8, Session.timeout - The number of minutes before CakePHP's session handler and non-SSL protocols, then you might have problems with sessions being lost. I have different groups of users, and for some group I need to give different session timeout. There is a question here, but it is not working. Different session timeouts for admin and users in CAKEPHP 2.0. is it possible?

I had the same problem in CakePHP 1.3

The problem was that CakePHP was using the settings defined in php.ini instead of the one I was defining in core.php

So I had to change in core.php:

Configure::write('', 'php');


Configure::write('', 'cake');

And it worked like a charm!

Session timeout not working in Cakephp 2, I've got a problem with a session duration in Cakephp 2. I set up my Config/core.​php file according to the Cakephp documentation: Configure::write('Session',  There's session timeout, and there's session cookie lifetime. The latter isn't affected by the former, which is configurable in the CakePHP configuration as shown in your code snippet, and is handled by CakePHPs session handler. Check your PHP installations session.cookie_lifetime setting, it might be the

How to extend session timeout when the user is idle with cakephp 2.x, Session timeout not working in Cakephp 2. I need to define a very large session time on a cakephp 2 application due to a business need. I defined it on the  After some more research I found that cakePHP resets the session on ajax requests. Some answer suggest to set checkAgent to false in core.php but this doesn't solve my problem. In CakePHP 1.x it as possible to lower the security level to solve the problem but that option is not available in 2.x – Ronny vdb Nov 8 '13 at 19:03

Cakephp Sessions not working properly, I tried setting the session timeout to 3 days, still same problem. Also tried to switch to database session (in core session configuration) still same  CakePHP provides a wrapper and suite of utility features on top of PHP’s native session extension. Sessions allow you to identify unique users across requests and store persistent data for specific users. Unlike Cookies, session data is not available on the client side. Usage of $_SESSION is generally avoided in CakePHP, and instead usage of the Session classes is preferred.

Cakephp session timeout issue resolved, Its working fine!! Sangeeta is very talented cake php developer……….its very use full Reply. Session.cookieTimeout - The number of minutes before the session cookie expires. If this is undefined, it will use the same value as Session.timeout. This affects the session cookie, and is handled by PHP itself. Session.checkAgent - Should the user agent be checked, on each request. If the user agent does not match the session will be destroyed.

  • You can use cookie to save and retrieve the user's detail
  • I did this but still logging me out after about 30min
  • Have you check you php.ini session.gc-maxlifetime paramter? if you are using default php session, I was wondering to know if cakephp can overwrite the php.ini setting. the default value of php to clean up session files is 1440 second, around 24 minutes.…
  • Might improve your answer by guiding OP on cookie_lifetime use.
  • This will increase the cookies expire time not the session timeout time...