Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Fix only number as session key will result in numbered session keys #51611

Merged
merged 2 commits into from
May 29, 2024
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
2 changes: 1 addition & 1 deletion src/Illuminate/Session/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function start()
*/
protected function loadSession()
{
$this->attributes = array_merge($this->attributes, $this->readFromHandler());
$this->attributes = array_replace($this->attributes, $this->readFromHandler());

$this->marshalErrorBag();
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Session/SessionStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ protected function tearDown(): void
public function testSessionIsLoadedFromHandler()
{
$session = $this->getSession();
$session->getHandler()->shouldReceive('read')->once()->with($this->getSessionId())->andReturn(serialize(['foo' => 'bar', 'bagged' => ['name' => 'taylor']]));
$session->getHandler()->shouldReceive('read')->once()->with($this->getSessionId())->andReturn(serialize(['foo' => 'bar', 'bagged' => ['name' => 'taylor'], '123' => 'bax']));
$session->start();

$this->assertSame('bar', $session->get('foo'));
$this->assertSame('bax', $session->get('123'));
$this->assertSame('baz', $session->get('bar', 'baz'));
$this->assertTrue($session->has('foo'));
$this->assertTrue($session->has('123'));
$this->assertFalse($session->has('bar'));
$this->assertTrue($session->isStarted());

Expand Down