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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Enh #86: Remove `yiisoft/cookies` dependency (@vjik)
- Bug #86: `NullSession::getCookieParameters()` now returns proper cookie parameters instead of an empty array (@vjik)
- Bug #25: Fix reusing the previous session ID in `Session::open()` in long-running workers (@klsoft-web)

## 3.0.2 August 26, 2026

Expand Down
4 changes: 1 addition & 3 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ public function open(): void
return;
}

if ($this->sessionId !== null) {
session_id($this->sessionId);
}
session_id($this->sessionId ?? '');

try {
session_start($this->options);
Expand Down
13 changes: 13 additions & 0 deletions tests/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ public function testRegenerateIdOpensInactiveSession(): void
self::assertNotEquals($id, $session->getId());
}

public function testOpenDoesNotReuseIdOfClosedSession(): void
{
$firstSession = new Session();
$firstSession->open();
$firstId = $firstSession->getId();
$firstSession->close();

$secondSession = new Session();
$secondSession->open();

self::assertNotSame($firstId, $secondSession->getId());
}

public function testDiscard(): void
{
$session = $this->getSession();
Expand Down
Loading