Skip to content

Commit 26a9887

Browse files
author
rotimi
committed
Updated container creating method
1 parent b93eb45 commit 26a9887

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

tests/BaseControllerDependenciesTrait.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,28 @@ protected function getContainer(array $override_settings=[]): \Psr\Container\Con
120120
$path_2_locale_language_files = __DIR__ . DIRECTORY_SEPARATOR . 'fake-smvc-app-root' . $ds.'config'.$ds.'languages';
121121
$locale_obj->load($path_2_locale_language_files); //load local entries for base controller
122122

123+
if(session_status() !== \PHP_SESSION_ACTIVE) {
124+
125+
// Try to start or resume existing session
126+
127+
$sessionOptions = $c->get(ContainerKeys::APP_SETTINGS)[AppSettingsKeys::SESSION_START_OPTIONS];
128+
129+
if(isset($sessionOptions['name'])) {
130+
131+
////////////////////////////////////////////////////////////////
132+
// Set the session name first
133+
// https://www.php.net/manual/en/function.session-start.php
134+
// To use a named session, call session_name() before
135+
// calling session_start().
136+
//
137+
// https://www.php.net/manual/en/function.session-name.php
138+
////////////////////////////////////////////////////////////////
139+
session_name($sessionOptions['name']);
140+
}
141+
142+
session_start($sessionOptions);
143+
}
144+
123145
// Try to update to previously selected language if stored in session
124146
if (
125147
session_status() === PHP_SESSION_ACTIVE
@@ -165,8 +187,7 @@ protected function getContainer(array $override_settings=[]): \Psr\Container\Con
165187

166188
return $view_renderer;
167189
});
168-
169-
}
190+
} // if(!$psr11Container || $override_settings !== [])
170191

171192
return $psr11Container;
172193
} // protected function getContainer(array $override_settings=[]): \Psr\Container\ContainerInterface

0 commit comments

Comments
 (0)