Allow reuse of Session between requests
This commit is contained in:
parent
86a5d92ce7
commit
fd30f4a21d
@ -178,8 +178,10 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
if ($this->storage->getId() !== $id) {
|
||||
$this->storage->setId($id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -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());
|
||||
|
Reference in New Issue
Block a user