diff --git a/src/Storage/SessionStorage.php b/src/Storage/SessionStorage.php index 92e9997..155d9d8 100644 --- a/src/Storage/SessionStorage.php +++ b/src/Storage/SessionStorage.php @@ -27,7 +27,7 @@ public function set($key, $value) $this->validateKey($key); $name = $this->getStorageKeyId($key); - $_SESSION[$name] = $value; + $_SESSION[$name] = serialize($value); } /** @@ -38,7 +38,7 @@ public function get($key) $this->validateKey($key); $name = $this->getStorageKeyId($key); - return isset($_SESSION[$name]) ? $_SESSION[$name] : null; + return isset($_SESSION[$name]) ? unserialize($_SESSION[$name]) : null; } /** diff --git a/tests/Storage/SessionStorageTest.php b/tests/Storage/SessionStorageTest.php index 826ba09..5d01e00 100644 --- a/tests/Storage/SessionStorageTest.php +++ b/tests/Storage/SessionStorageTest.php @@ -26,7 +26,7 @@ public function setUp() public function testSet() { $this->storage->set('code', 'foobar'); - $this->assertEquals($_SESSION[$this->prefix.'code'], 'foobar'); + $this->assertEquals($_SESSION[$this->prefix.'code'], serialize('foobar')); } /** @@ -43,10 +43,9 @@ public function testGet() $result = $this->storage->get('state'); $this->assertNull($result); - $expected = 'foobar'; - $_SESSION[$this->prefix.'code'] = $expected; + $_SESSION[$this->prefix.'code'] = serialize('foobar'); $result = $this->storage->get('code'); - $this->assertEquals($expected, $result); + $this->assertEquals('foobar', $result); } public function testClear()