Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
zendframework/zendframework#6366 - session data is backed up and merg…
Browse files Browse the repository at this point in the history
…ed back into `$_SESSION` after `session_start()` (when not empty)

Signed-off-by: Marco Pivetta <ocramius@gmail.com>
  • Loading branch information
Ocramius authored and weierophinney committed Jan 14, 2015
1 parent 1272fc0 commit 7fc94bd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Zend\Session;

use Zend\EventManager\EventManagerInterface;
use Zend\Stdlib\ArrayUtils;

/**
* Session ManagerInterface implementation utilizing ext/session
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7fc94bd

Please sign in to comment.