Skip to content

Commit

Permalink
feat(admin): add setting to split admin and front-end session (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfrigge authored and rhukster committed Oct 12, 2016
1 parent 0cadb0c commit 6300ab8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions system/blueprints/config/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,18 @@ form:
label: PLUGIN_ADMIN.SESSION_PATH
help: PLUGIN_ADMIN.SESSION_PATH_HELP

session.split_admin:
type: toggle
label: PLUGIN_ADMIN.SESSION_SPLIT
help: PLUGIN_ADMIN.SESSION_SPLIT_HELP
highlight: 1
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
default: true
validate:
type: bool

advanced:
type: section
title: PLUGIN_ADMIN.ADVANCED
Expand Down
7 changes: 6 additions & 1 deletion system/src/Grav/Common/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ public function init()

$unique_identifier = GRAV_ROOT;
$inflector = new Inflector();
$this->setName($inflector->hyphenize($config->get('system.session.name', 'grav_site')) . '-' . substr(md5($unique_identifier), 0, 7) . ($is_admin ? '-admin' : ''));
$session_name = $inflector->hyphenize($config->get('system.session.name', 'grav_site')) . '-' . substr(md5($unique_identifier), 0, 7);
$split_admin_session = $config->get('system.session.split_admin', true);
if ($is_admin && $split_admin_session) {
$session_name .= '-admin';
}
$this->setName($session_name);
$this->start();
setcookie(session_name(), session_id(), time() + $session_timeout, $session_path, $domain, $secure, $httponly);
}
Expand Down

0 comments on commit 6300ab8

Please sign in to comment.