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?
Related
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
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
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.
)
);
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
I'm having a cookie issue, the expiry date on my cookie is always being set to At End Of Session which isn't what I want. I did a bit of goggling and it suggested it set the expire to time()+60*60*24*30 which I've done.
//Create basket cookie
$cookie = array(
'name' => 'basket_id',
'value' => $basket_id,
'expire' => time()+60*60*24*30,
'domain' => 'domain',
'path' => '/',
'prefix' => '',
);
set_cookie($cookie);
I did wonder if it could be down to a Codeignter setting but my ci_session cookie has a normal expiry date. Thu, 09 Jun 2011 10:39:02 GMT
This is what I get when I view the cookie:
Name basket_id
Value 28
Host .host
Path /
Secure No
Expires At End Of Session
And here is an example of the array I'm passing to the cookie.
Array ( [name] => basket_id [value] => 30 [expire] => 1310202067 [domain] => host [path] => / [prefix] => )
Your expiry date is set incorrectly. You don't have to include the time(), as what you're setting is actually the expiry date from time().
When you have an incorrect expire value, it defaults to 0, which is set as your session's length instead.
Therefore it should be:
$cookie = array(
'name' => 'basket_id',
'value' => $basket_id,
'expire' => 86400*30,
'domain' => 'domain',
'path' => '/',
'prefix' => '',
);
Please check out the answer below by #Gowri for how to do it properly.
You can try to adjust session expiration time in config.php CI session initially is saved in cookies:
/** Session Variables
---------------------------------------
| 'session_expiration' = the number of SECONDS you want the session to last.
| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
|
*/
$config['sess_expiration'] = 7200;
You can add params
$config['cookie_lifetime'] = 1800
in config.php, the reason you can find in libraries/Sessions/Session.php, code below
$expiration = config_item('sess_expiration');
if (isset($params['cookie_lifetime']))
{
$params['cookie_lifetime'] = (int) $params['cookie_lifetime'];
}
else
{
$params['cookie_lifetime'] = (!isset($expiration) && config_item('sess_expire_on_close'))
? 0 : (int) $expiration;
}