diff --git a/src/controllers/BaseController.php b/src/controllers/BaseController.php index e534b23..3814e54 100644 --- a/src/controllers/BaseController.php +++ b/src/controllers/BaseController.php @@ -246,6 +246,15 @@ public function __construct( $this->updateSelectedLanguage(); } + protected function startSession(): void { + + $session_start_settings = + $this->getAppSetting('session_start_options') !== null + ? (array)$this->getAppSetting('session_start_options') + : []; + session_start($session_start_settings); + } + /** * @psalm-suppress InvalidScalarArgument */ @@ -272,11 +281,7 @@ public function updateSelectedLanguage() : void { if (session_status() !== \PHP_SESSION_ACTIVE) { - $session_start_settings = - $this->getAppSetting('session_start_options') !== null - ? (array)$this->getAppSetting('session_start_options') - : []; - session_start($session_start_settings); + $this->startSession(); } // also store in session @@ -748,11 +753,7 @@ protected function doLogin(\Vespula\Auth\Auth $auth, array $credentials, string //since we are successfully logged in, resume session if any if (session_status() !== \PHP_SESSION_ACTIVE) { - $session_start_settings = - $this->getAppSetting('session_start_options') !== null - ? (array)$this->getAppSetting('session_start_options') - : []; - session_start($session_start_settings); + $this->startSession(); } } else { @@ -1033,11 +1034,7 @@ public function storeCurrentUrlForLoginRedirection(): self { //start a new session if none exists if(session_status() !== \PHP_SESSION_ACTIVE) { - $session_start_settings = - $this->getAppSetting('session_start_options') !== null - ? (array)$this->getAppSetting('session_start_options') - : []; - session_start($session_start_settings); + $this->startSession(); } //store current url in session