diff --git a/composer.json b/composer.json index 6992bb56..4eb867cc 100755 --- a/composer.json +++ b/composer.json @@ -28,12 +28,10 @@ "flextype-components/arrays" : "3.0.1", "flextype-components/strings" : "1.2.0", - "flextype-components/cookie" : "1.2.0", "flextype-components/filesystem" : "2.0.8", "flextype-components/i18n" : "1.3.0", "flextype-components/number" : "1.1.1", "flextype-components/registry" : "3.0.0", - "flextype-components/session" : "1.1.1", "slim/slim": "~3.12.3", @@ -59,7 +57,8 @@ "thunderer/shortcode": "~0.7.4", - "composer/semver": "~3.0.1" + "composer/semver": "~3.0.1", + "odan/session": "^5.0" }, "suggest": { "ext-zend-opcache": "Recommended for better performance", diff --git a/src/flextype/bootstrap.php b/src/flextype/bootstrap.php index 6ffd075d..12229a75 100755 --- a/src/flextype/bootstrap.php +++ b/src/flextype/bootstrap.php @@ -10,7 +10,6 @@ declare(strict_types=1); namespace Flextype; use Flextype\Component\Registry\Registry; -use Flextype\Component\Session\Session; use Flextype\Foundation\Flextype; use Slim\Http\Environment; use Slim\Http\Uri; @@ -30,11 +29,6 @@ use function mb_regex_encoding; use function str_replace; use function ucwords; -/** - * Start the session - */ -Session::start(); - /** * Init Registry */ @@ -109,6 +103,18 @@ if ($registry->get('flextype.settings.errors.display')) { */ include_once 'dependencies.php'; +/** + * Set session options before you start the session + * Standard PHP session configuration options + * https://secure.php.net/manual/en/session.configuration.php + */ +flextype('session')->setOptions(flextype('registry')->get('flextype.settings.session')); + +/** + * Start the session + */ +flextype('session')->start(); + /** * Include API ENDPOINTS */ diff --git a/src/flextype/dependencies.php b/src/flextype/dependencies.php index 5c8894c4..a712db04 100644 --- a/src/flextype/dependencies.php +++ b/src/flextype/dependencies.php @@ -12,6 +12,7 @@ namespace Flextype; use Bnf\Slim3Psr15\CallableResolver; use Cocur\Slugify\Slugify; use Flextype\Component\Strings\Strings; +use Odan\Session\PhpSession; use Flextype\Foundation\Cors; use Flextype\Foundation\Entries\Entries; use Flextype\Foundation\Media\MediaFiles; @@ -57,6 +58,13 @@ use function extension_loaded; use function in_array; use function sys_get_temp_dir; +/** + * Create a standard session hanndler + */ +flextype()->container()['session'] = static function () { + return new PhpSession(); +}; + /** * Supply a custom callable resolver, which resolves PSR-15 middlewares. */ diff --git a/src/flextype/settings.yaml b/src/flextype/settings.yaml index 7333d280..3883711f 100644 --- a/src/flextype/settings.yaml +++ b/src/flextype/settings.yaml @@ -398,6 +398,14 @@ media: max_image_width: null max_image_height: null +# Session +# +# Set session options before you start the session +# Standard PHP session configuration options +# https://secure.php.net/manual/en/session.configuration.php +session: + name: Flextype + # Content APIs api: entries: