diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml index c9575a843da84..8092a5972417b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/session.xml @@ -11,6 +11,8 @@ Symfony\Component\HttpFoundation\SessionStorage\PdoSessionStorage + Symfony\Component\HttpFoundation\SessionStorage\ArraySessionStorage + @@ -30,6 +32,10 @@ %session.storage.pdo.options% + + %session.storage.array.options% + + diff --git a/src/Symfony/Component/HttpFoundation/SessionStorage/ArraySessionStorage.php b/src/Symfony/Component/HttpFoundation/SessionStorage/ArraySessionStorage.php new file mode 100755 index 0000000000000..dbb1c6bf627a6 --- /dev/null +++ b/src/Symfony/Component/HttpFoundation/SessionStorage/ArraySessionStorage.php @@ -0,0 +1,51 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * ArraySessionStorage. + * + * @author Fabien Potencier + * @author Bulat Shakirzyanov + */ + +class ArraySessionStorage implements SessionStorageInterface +{ + private $data = array(); + + public function read($key, $default = null) + { + return array_key_exists($key, $this->data) ? $this->data[$key] : $default; + } + + public function regenerate($destroy = false) + { + if ($destroy) { + $this->data = array(); + } + return true; + } + + public function remove($key) + { + unset($this->data[$key]); + } + + public function start() + { + } + + public function write($key, $data) + { + $this->data[$key] = $data; + } +}