I need to increase the session time for logged in users on my project. This is the session info in core.php:
Configure::write('Session', array(
'defaults' => 'php',
'cookieTimeout' => 1440,
'autoRegenerate' => true,
'cookie' => 'SYNAPARTY'
));
This generates a cookie that expires in 24 hours. The problem is the user gets logged out after sometime of inactivity. How can I solve this?
Try changing it to:
Configure::write('Session', array(
'defaults' => 'php',
'cookieTimeout' => 1440,
'timeout' => 1440 //Or whatever amount of minutes you want
'autoRegenerate' => true,
'cookie' => 'SYNAPARTY'
));
Related
I tried many options in config.php file but no success.
Here the options.
first one:
Configure::write('Session', array(
'defaults' => 'php',
'timeout' => 31556926, // The session will timeout after 30 minutes of inactivity
'cookieTimeout' => 31556926,
'ini' => array(
'session.gc_maxlifetime' => 31556926 // 36 hours
)
));
second one:
Configure::write('Session', array(
'defaults' => 'php',
'Session.timeout' => 36000
));
Please let me know, as session expires in middle of work!
use the following code in your (app/Config/core.php)
Configure::write('Session', array(
'defaults' => 'cake',
'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
));
I need to define a very large session time on a cakephp 2 application due to a business need. I defined it on the core.php file as follows:
Configure::write('Session', array(
'defaults' => 'php', //defaults => php
'cookie' => 'cookie',
'timeout' => 4320 // 3 days
));
I made a test and arround two hours of inactivity my session is closed, every time I click a button I get back to the logon screen, how can I effectively control my session time?
Use this It may work.it is working for me
core.php
Configure::write('Session', array(
'defaults' => 'php',
'timeout' => 259200,
'ini' => array(
'session.gc_maxlifetime' => 259200 // 3 day
)
));
How to do auto logout after some minute if the user is idle
I am using yii framework.
I can set logout time under user component in main.php
but the question is how to check the user is idle?
if(isset(Yii::app()->request->cookies['lastpageview']) && (time()-(int)Yii::app()->request->cookies['lastpageview']->value > 3600))
{
//logout
}
else
{
Yii::app()->request->cookies['lastpageview'] = new CHttpCookie('lastpageview', time());
}
where 3600 is the max number or seconds allowed
For Yii 1.xx CWebUser has property authTimeout.
From off documentation:
authTimeout - timeout in seconds after which user is logged out if
inactive.
Set it propety into main config:
...
'components' => array(
....
'user' => array(
'authTimeout' => 60*60*5,
),
....
),
...
You can use CDbHttpSession component to make it work:
'components' => array(
'session' => array(
'class' => 'CDbHttpSession',
'timeout' => 1,
),
),
'user' => [
'identityClass' => 'app\models\User',
//'enableAutoLogin' => true,
'enableSession' => true,
'authTimeout' => 900,
],
its working fine to me!(YII 2.0)
time out session after 15 min if request is come after 15 min then auto redirect to site/login page.
I am trying to implement a "Single Sign On (SSO)" between my CakePHP script and my wordpress blog. I researched online for it and found some questions such as
Access cakephp session (auth) from outside cakephp
and
Accessing cakephp session variable from a php script?
To do a quick test I then created a test php file in my webroot directory of my CakePHP with below code
<?php
session_name('NMCORE');
session_start();
print_r($_SESSION);
?>
NMCORE is my session name. It's not the default CAKEPHP. I also confirmed it by putting debug(session_name()); in my controller. But the above code returns a blank array. I'm not sure why it's not working. I need your help to figure it out.
The configuration for my Session in my CakePHP's core.php file is
Configure::write('Session', array(
'defaults' => 'cake',
'cookie' => 'NMCORE',
'timeout' => 43200, //30 days
'autoRegenerate' => true,
'checkAgent' => true
));
Does anybody have an idea on why this is not working?
I figured that out. I'm using 'defaults' => 'cake' in my
Configure::write('Session', array(
'defaults' => 'cake',
'cookie' => 'NMCORE',
'timeout' => 43200, //30 days
'autoRegenerate' => true,
'checkAgent' => true
));
When I changed it to 'php' then it worked.
Configure::write('Session', array(
'defaults' => 'php',
'cookie' => 'NMCORE',
'timeout' => 43200, //30 days
'autoRegenerate' => true,
'checkAgent' => true
));
i'm trying to set a life time to the cookie sessions in my yii application
in the main.confg file i added the following ...
'session' => array(
'class' => 'CCacheHttpSession',
'cacheID' => 'cache',
'timeout' => 604800, // 7 days
'sessionName' => 'zii_s',
'cookieParams' => array(
'domain' => '***',
'path' => '/',
'httponly' => true,
'lifetime' => 100000,//this field
),
),
as soon as the life time value is set the session is not saved but when i remove it or setting its value to ZERO the session is saved
*Update: the set cookie flag exists in the HTTP response and its
Set-Cookie:zii_s=j0scslhn7q3s0fib4gns3etl01; expires=Thu, 05-Jul-2012 16:00:54 GMT; path=/; domain=*; HttpOnly*
can anyone tell me why ?