Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 1e128d6

Browse files
committed
Merge pull request #45 from necromant2005/master
skip session regenerate id when session is not started
2 parents f5475c4 + 9749afd commit 1e128d6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/SessionManager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,10 @@ public function getId()
320320
*/
321321
public function regenerateId($deleteOldSession = true)
322322
{
323-
session_regenerate_id((bool) $deleteOldSession);
323+
if ($this->sessionExists()) {
324+
session_regenerate_id((bool) $deleteOldSession);
325+
}
326+
324327
return $this;
325328
}
326329

test/SessionManagerTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,17 @@ public function testRegenerateIdShouldWorkAfterSessionStarted()
433433
$this->assertNotSame($origId, $this->manager->getId());
434434
}
435435

436+
/**
437+
* @runInSeparateProcess
438+
*/
439+
public function testRegenerateIdDoesNothingWhenSessioIsNotStarted()
440+
{
441+
$origId = $this->manager->getId();
442+
$this->manager->regenerateId();
443+
$this->assertEquals($origId, $this->manager->getId());
444+
$this->assertEquals('', $this->manager->getId());
445+
}
446+
436447
/**
437448
* @runInSeparateProcess
438449
*/

0 commit comments

Comments
 (0)