Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow reuse of Session between requests
  • Loading branch information
tgalopin committed Sep 21, 2018
commit fd30f4a21d6f44dda89a13f01f222d29aa270aed
4 changes: 3 additions & 1 deletion src/Symfony/Component/HttpFoundation/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ public function getId()
*/
public function setId($id)
{
$this->storage->setId($id);
if ($this->storage->getId() !== $id) {
$this->storage->setId($id);
}
}

/**
Expand Down
21 changes: 21 additions & 0 deletions src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ public function testSetId()
$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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function setUp()
$this->data = array(
$this->attributes->getStorageKey() => array('foo' => 'bar'),
$this->flashes->getStorageKey() => array('notice' => 'hello'),
);
);

$this->storage = new MockArraySessionStorage();
$this->storage->registerBag($this->flashes);
Expand Down