Allow reuse of Session between requests

This commit is contained in:
Titouan Galopin 2018-09-10 21:53:03 +02:00
parent 86a5d92ce7
commit fd30f4a21d
3 changed files with 25 additions and 2 deletions

View File

@ -178,8 +178,10 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
*/
public function setId($id)
{
if ($this->storage->getId() !== $id) {
$this->storage->setId($id);
}
}
/**
* {@inheritdoc}

View File

@ -70,6 +70,27 @@ class SessionTest extends TestCase
$this->assertEquals('0123456789abcdef', $this->session->getId());
}
public function testSetIdAfterStart()
{
$this->session->start();
$id = $this->session->getId();
$e = null;
try {
$this->session->setId($id);
} catch (\Exception $e) {
}
$this->assertNull($e);
try {
$this->session->setId('different');
} catch (\Exception $e) {
}
$this->assertInstanceOf('\LogicException', $e);
}
public function testSetName()
{
$this->assertEquals('MOCKSESSID', $this->session->getName());