Cakephp Session expiration doesn't work? - session

I'm pretty new to Cakephp. I'd like my sessions data gets expired in 3 days. However, it seems like the expiration time is just a few hours, as when the user logs in, s/he will be logged out in a few hours.
Here is all the changes I have made in core.php:
I added timeout parameter:
Configure::write('Session', array(
'defaults' => 'php',
'timeout' => 4320
));
I checked most of the relevant questions and none of the solutions worked for me:
Changing 'timeout' to 'session.timeout', changing 4320 to '4320' and ,...
Thanks for you help in advance. :)

You can use below code for same:
Configure::write('Session', array(
'defaults' => 'php',
'timeout' => 30, // The session will timeout after 30 minutes of inactivity
'cookieTimeout' => 1440, // The session cookie will live for at most 24 hours, this does not effect session timeouts
'checkAgent' => false,
'autoRegenerate' => true, // causes the session expiration time to reset on each page load
));
Read more here

Related

Cakephp3 cache duration not expiring

Hello everyone I work with cakephp3 I have implemented the cache from doc but the duration to expire the cache does not apply.
I tried to use minutes and hours in the duration but it doesn't work
thanks for your help.
Here is my cache configuration
'Cache' => [
'access_token' => [
'className' => 'File',
'duration' => '+2 minutes',
'path' => CACHE
]
],
and here I created my cache with my configuration:
Cache::write("access_token\_$key", $response, 'access_token');
The cache does not expire after 2 minutes, I also tried to use +1 hours instead of +2 minutes but still it does not work

Cakephp session cookie name using wrong

My cakephp session cookie using PHPSESSID instead of user defined
here is the image, i try to get session name used by this application debug(session_name());, it show PHPSESSID instead of makassarterkini
is there something i need to configure in php.ini?
Take a look at your CakePHP session configuration.
For example:
//core.php
Configure::write('Session', array(
'defaults' => 'php',
'cookie' => 'stackoverflowexample',
'timeout' => '43200',
'cookieTimeout' => '43200'
));
I can access this session using:
$this->Session->read('stackoverflowexample.somevalue');

Laravel lost session after a few requests/page refresh

Unfortunately I have a problem with the laravel-session:
When I add a few products to the sessioned shopping-cart and reload the page a few times, the session-data will be lost completely.
The session config:
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 120,
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => null,
'table' => 'sessions',
'lottery' => [2, 100],
'cookie' => 'laravel_session',
'path' => '/',
'domain' => null,
'secure' => false,
'http_only' => true,
(all the default)
Laravel Version:
5.2.43
The issue appears locally (xampp) and on the server (forge). So I suspect that there is not a server problem.
I've tried different solutions with the middleware, but unfortunately without any success. It looks like, the session were deleted after some requests/page reloads randomly. (sometimes after 5, sometimes by 20)
I found out when I load images per request (not directly via file), the session will be lost more often.
Session-percistence is apparently a big problem for laravel-beginners.
So many boards and forums are full of solutions, but nothing i found solves my problem.
Is there any experience?
Thanks!
it seems "Session Sweeping Lottery" is not the trigger for my problem.
Does anybody here has an idea? I'm helpless at the moment.

CakePHP 3 losing Auth Session

I am using Auth Session in CakePHP.
'Session' => [
'timeout' => 0,
'defaults' => 'php',
'ini' => [
'session.cookie_secure' => false,
'session.cookie_lifetime' => 0
]
],
Already configured this in tha app.php but still getting logged out after few minutes.
Although Session persists when closing Browser. So i think its just a time related problem.
I was having requirement to increase session timeout in cakphp 2.5
the following code worked for me in 2.5 you can give this a try
//FILE: config/core.php
Configure::write('Session', array(
'defaults' => 'cake',
'cookie' => 'my_app',
'timeout' => 500, // 8 hours + 20 min, user will be logged in till 8 hours.
)
);

Increase user (Auth) session in CakePHP

I'm handling the authentication for my with Auth CakePHP. The user session is very low, thus the user logs out quickly after being idle for about 30 mins. This is what I did which doesn't really work:
Configure::write('Session', array(
'defaults' => 'php',
'timeout' => 259200, // 72 hours
'cookieTimeout' => 259200 // 72 hours
)
);
FYI:
Configure::write('debug', 2);
Is there anything else I should do?

Resources