From 7fc94bd6a60342416242a3899d63072c471b33d3 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 28 Dec 2014 20:45:24 +0100 Subject: [PATCH] zendframework/zf2#6366 - session data is backed up and merged back into `$_SESSION` after `session_start()` (when not empty) Signed-off-by: Marco Pivetta --- src/SessionManager.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/SessionManager.php b/src/SessionManager.php index b90ed437..77219f64 100644 --- a/src/SessionManager.php +++ b/src/SessionManager.php @@ -10,6 +10,7 @@ namespace Zend\Session; use Zend\EventManager\EventManagerInterface; +use Zend\Stdlib\ArrayUtils; /** * Session ManagerInterface implementation utilizing ext/session @@ -92,8 +93,16 @@ public function start($preserveStorage = false) $this->registerSaveHandler($saveHandler); } + $oldSessionData = $_SESSION; + session_start(); + if ($oldSessionData instanceof \Traversable + || (! empty($oldSessionData) && is_array($oldSessionData)) + ) { + $_SESSION = ArrayUtils::merge($oldSessionData, $_SESSION, true); + } + $storage = $this->getStorage(); // Since session is starting, we need to potentially repopulate our