mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2040 from sminnee/session-timeout-fixes
Session timeout fixes
This commit is contained in:
commit
9511d72aa9
@ -152,6 +152,15 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
*/
|
||||
private static $extra_requirements_themedCss = array();
|
||||
|
||||
/**
|
||||
* If true, call a keepalive ping every 5 minutes from the CMS interface,
|
||||
* to ensure that the session never dies.
|
||||
*
|
||||
* @config
|
||||
* @var boolean
|
||||
*/
|
||||
private static $session_keepalive_ping = true;
|
||||
|
||||
/**
|
||||
* @var PjaxResponseNegotiator
|
||||
*/
|
||||
@ -327,16 +336,13 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
|
||||
HTMLEditorField::include_js();
|
||||
|
||||
Requirements::combine_files(
|
||||
'leftandmain.js',
|
||||
array_unique(array_merge(
|
||||
$leftAndMainIncludes = array_unique(array_merge(
|
||||
array(
|
||||
FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Layout.js',
|
||||
FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.js',
|
||||
FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.ActionTabSet.js',
|
||||
FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Panel.js',
|
||||
FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Tree.js',
|
||||
FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Ping.js',
|
||||
FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Content.js',
|
||||
FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.EditForm.js',
|
||||
FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Menu.js',
|
||||
@ -347,8 +353,13 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
),
|
||||
Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/javascript/lang', true, true),
|
||||
Requirements::add_i18n_javascript(FRAMEWORK_ADMIN_DIR . '/javascript/lang', true, true)
|
||||
))
|
||||
);
|
||||
));
|
||||
|
||||
if($this->config()->session_keepalive_ping) {
|
||||
$leftAndMainIncludes[] = FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Ping.js';
|
||||
}
|
||||
|
||||
Requirements::combine_files('leftandmain.js', $leftAndMainIncludes);
|
||||
|
||||
// TODO Confuses jQuery.ondemand through document.write()
|
||||
if (Director::isDev()) {
|
||||
|
@ -535,6 +535,13 @@ class Session {
|
||||
// There's nothing we can do about this, because it's an operating system function!
|
||||
if($sid) session_id($sid);
|
||||
@session_start();
|
||||
|
||||
}
|
||||
|
||||
// Modify the timeout behaviour so it's the *inactive* time before the session expires.
|
||||
// By default it's the total session lifetime
|
||||
if($timeout && !headers_sent()) {
|
||||
setcookie(session_name(), session_id(), time()+$timeout, $path, $domain ? $domain : null, $secure, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user