Cakephp3 cache duration not expiring - caching

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

Related

Cakephp3 Change cache duration in controller

Hello everyone I work with cakephp3 here is my cache configuration in app.php
'Cache' => [
'access_token' => [
'className' => 'File',
'duration' => '+2 minutes',
'path' => CACHE
]
],
I set the duration to 2 minutes but I need to dynamically change the duration via my Controller.
I I tried setConfig but it does not work
Cache::write("access_token_$key", $response, 'access_token');
Cache::setConfig("access_token_$key", array('duration' => $time));
Also i tried this but still does not work
$engine = Cache::engine("access_token_$key");
$engine->config("duration", $time);
Thanks for any help

Yii2 set session timeout - I am unble to set session timeout in yii2

Below is the configuration I used backend/config/main.php in my application But still I am unable to set session timeout.
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'authTimeout' => 3600,
],'session' => [
'class' => 'yii\web\Session',
'cookieParams' => ['httponly' => true, 'lifetime' => 3600 * 4],
'timeout' => 3600*4,
'useCookies' => true,
],
My requirements are
1.Expire session if inactive of user more than 30 minutes
2.If browser is closed, don't set session expire before 30 mins.
Thank in advance

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.
)
);

Cakephp Session expiration doesn't work?

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

Resources